Description
TypeScript Version: tried 2.2.1 and 2.5.2
Code
src/file1.ts
export type myType = {anything : number};
src/file2.ts
import { myType } from '@src/file1';
export type myOtherType = {anythingElse : number} & myType;
tsconfig.json
{
"compilerOptions": {
"outDir": "./dist",
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"declaration": true,
"noImplicitAny": true,
"removeComments": true,
"sourceMap": true,
"strictNullChecks": true,
"noImplicitThis": true,
"noImplicitReturns": true,
"noUnusedParameters": true,
"noUnusedLocals": true,
"baseUrl": ".",
"paths": {
"@src/*": ["./src/*"]
},
"lib": ["es2017", "dom"]
},
"compileOnSave": false,
"include": [
"src/**/*",
"app/**/*"
],
"exclude": [
"node_modules",
"dist"
]
}
Expected behavior:
i should be able to import myOtherType in a different package (after say publishing this to npm, with the typings
field set to dist/file2.d.ts
) without errors
Actual behavior:
typescript says Cannot find module "@src/file1"
when compiling any package that consumes these types.
Note: the runtime behavior works properly in my case because i'm handling the module resolution through webpack. It's only the types that are failing and I'm curious how the paths property could be expected to work outside of the package in which they are defined. Is that property simply not meant to be used in a library style package that's being written for external consumption?