Environment
Express.JS application using express-file-routing for file-based routing.
Directory structure
├── index.ts
└── src/
├── services/
├── controllers/
│ └── health.controller.ts
├── middlewares/
├── interfaces/
└── routes/
└── health.ts
tsconfig.json
"paths": {
"@controllers/*": ["src/controllers/*.controller"],
"@services/*": ["src/services/*.service"],
"@middlewares/*": ["src/middlewares/*.middleware"],
"@interfaces/*": ["src/interfaces/*.interface"]
},
What doesn't work?
Suppose I have the following file
import {checkHealth} from '@controllers/health';
import type {Handler} from 'express';
export const get: Handler = async (request, response) => {
response.json({status: checkHealth()});
};
TypeScript will output the following
import { checkHealth } from '@controllers/health';
export const get = async (request, response) => {
response.json({ status: checkHealth() });
};
Expected behaviour
tsc-alias should be able to resolve correctly
Results
tsc-alias doesn't resolve
Workaround
Remove any suffix from path aliases and it will work correctly.
Environment
Express.JS application using
express-file-routingfor file-based routing.Directory structure
tsconfig.jsonWhat doesn't work?
Suppose I have the following file
TypeScript will output the following
Expected behaviour
tsc-aliasshould be able to resolve correctlyResults
tsc-aliasdoesn't resolveWorkaround
Remove any suffix from path aliases and it will work correctly.