Is there a way to declare a path to a referenced folder in order to have a more concise import statement using the @resources path?
- I am building from /server by running tsc -b
app.ts
The following long import statement works:
import IEntity from
'../../model/src/resources/entity/entity.interface';
However, this shorter one does NOT work:
import IEntity from
'@resources/entity/entity.interface';
Folder structure:
/
/model
/src
/resources
/entitiy
entity.interface.ts
tsconfig.json
/server
/src
app.ts
tsconfig.json
entity.interface.ts
import { Document } from 'mongoose';
export default interface IEntity extends Document {
name: string;
}
tsconfig.json (under /server)
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"declaration": true,
"declarationMap": true,
"outDir": "dist",
// "rootDir": "./",
// "composite": true,
// "isolatedModules": true,
"strict": true,
// "moduleResolution": "node",
"baseUrl": ".",
"paths": {
"@resources" : ["../model/src/resources"]
},
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
},
"include": ["src/**/*"],
"references": [{
"path": "../model/"
}]
}
tsconfig.json (under /model)
{
"compilerOptions": {
"composite": true,
"target": "es2016",
"module": "commonjs",
"outDir": "dist",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true
}
}