I am relatively new to typescript so maybe I am missing something here or don't fully understand the concept. In tsconfig I have defined the following in compilerOptions:
{
baseUrl: ".",
paths: {
"*": ["server/*"]
}
}
Assuming the following directory structure:
+ server
| + routes
| | + util
| | - config.routes.ts
| - route_file.ts
-tsconfig.json
If I import a module exported by route_file.ts in config.routes.ts:
import * as routes from 'routes/route_file.ts';
Typescript resolves the path without issue. The compiled JS, however, requires the module with the same literal path:
const routes = require('routes/route_file')
This is obviously a problem because the module will not be found as the path should be ../route_file. My project has quite a few sub directories and I was hoping to get away from ../../../ if possible. Is there a way to make the compiler check the directory of the importing file and update the require path relative to that file?