TypeScript Version: 2.9.2
Search Terms: declaration file inline import, declaration files import path error
Code
In src/lib/operators/scalar.ts
exportinterfaceScalar{(): stringvalue: numberunit: Unitadd(value: Scalable): this
subtract(value: Scalable): this
multiply(value: Scalable): this
divide(value: Scalable): this
get(): stringtoString(): string}exportfunctionscalar(value: string): Scalar{returnparseScalar(value)// returns an object of type scalar}In src/settings/spacing.ts
import{scalar}from'../lib/operators/scalar'constbaseSpacing="14px"exportdefault{getxs(){returnscalar(baseSpacing).divide(4)// returns an object of type Scalar}})Expected behavior:
In dist/settings/spacing.d.ts
import{Scalar}from"../lib/operators/scalar"exportdefault{readonlyxs: Scalar}Actual behavior:
In dist/settings/spacing.d.ts
exportdefault{readonlyxs: import("src/lib/operators/scalar").Scalar}NOTES:
- Should it import inline? (tslint complains that it shouldn't)
- The path should be "../lib/operators/scalar"
Local tsconfig.json
{
"extends": "./../../tsconfig.json",
"compilerOptions": {
"baseUrl": "./",
"paths": {
"*": ["node_modules/@types/*", "*"]
},
"outDir": "./dist",
"rootDir": "./src",
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"allowJs": false,
"declaration": true,
"jsx": "react",
"sourceMap": true
},
"include": ["./src/**/*"],
"exclude": [
"node_modules",
"src/**/__tests__/",
"build",
"dist",
"scripts",
"acceptance-tests",
"webpack",
"jest",
"src/setupTests.ts",
"webpack.config.js"
]
}Main tsconfig.json
{
"compilerOptions": {
"baseUrl": "",
"module": "esnext",
"target": "es5",
"lib": ["dom", "esnext", "es6"],
"sourceMap": true,
"allowJs": true,
"jsx": "react",
"moduleResolution": "node",
"rootDir": "src",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": false,
"strictNullChecks": true,
"suppressImplicitAnyIndexErrors": true,
"noUnusedLocals": true,
"paths": {
"@libs/components": ["Libs/Components/dist/index.js"]
}
}
}
TypeScript Version: 2.9.2
Search Terms: declaration file inline import, declaration files import path error
Code
In src/lib/operators/scalar.ts
In src/settings/spacing.ts
Expected behavior:
In dist/settings/spacing.d.ts
Actual behavior:
In dist/settings/spacing.d.ts
NOTES:
Local tsconfig.json
{ "extends": "./../../tsconfig.json", "compilerOptions": { "baseUrl": "./", "paths": { "*": ["node_modules/@types/*", "*"] }, "outDir": "./dist", "rootDir": "./src", "target": "es5", "module": "commonjs", "moduleResolution": "node", "allowSyntheticDefaultImports": true, "allowJs": false, "declaration": true, "jsx": "react", "sourceMap": true }, "include": ["./src/**/*"], "exclude": [ "node_modules", "src/**/__tests__/", "build", "dist", "scripts", "acceptance-tests", "webpack", "jest", "src/setupTests.ts", "webpack.config.js" ] }Main tsconfig.json
{ "compilerOptions": { "baseUrl": "", "module": "esnext", "target": "es5", "lib": ["dom", "esnext", "es6"], "sourceMap": true, "allowJs": true, "jsx": "react", "moduleResolution": "node", "rootDir": "src", "forceConsistentCasingInFileNames": true, "noImplicitReturns": true, "noImplicitThis": true, "noImplicitAny": false, "strictNullChecks": true, "suppressImplicitAnyIndexErrors": true, "noUnusedLocals": true, "paths": { "@libs/components": ["Libs/Components/dist/index.js"] } } }