Context:
- Generating declaration files
Declaration emit reveals paths within dependency that were not referred to in the source file:
exportdeclareconstinstance: import("dependency/internal-types").TheInterface;This is a problem because changing paths within a dependency can break a dependent package.
TypeScript Version: 3.9.0-dev.20200212
Search Terms:
Code
node_modules/@types/dependency/entrypoint.d.ts
import{TheInterface}from"./internal-types";export{TheInterface};exportdeclarefunctiongetInstance(): TheInterface;node_modules/@types/dependency/internal-types.d.ts
exportinterfaceTheInterface{}node_modules/@types/dependency/index.d.ts
// empty - doesn't matter for this example
example.ts
import{getInstance}from"dependency/entrypoint";exportconstinstance=getInstance();src/app/tsconfig.json
{
"compilerOptions": {
"declaration": true,
}
}Expected behavior:
example.d.ts
exportdeclareconstinstance: import("dependency/entrypoint").TheInterface;Actual behavior:
example.d.ts
exportdeclareconstinstance: import("dependency/internal-types").TheInterface;It seems that part of the solution could involve having the compiler avoid using relative paths in types (import("<relativepath>").<typename>) if the relativepath is outside the project.
Repro Repo:https://github.com/mheiber/repro-rel-import-inlining
Related Issues:
Issue written with the help of: Robin Ricard (@rricard), Rob Palmer (@robpalme) and Kubilay Kahveci (@mkubilayk)
Context:
Declaration emit reveals paths within dependency that were not referred to in the source file:
This is a problem because changing paths within a dependency can break a dependent package.
TypeScript Version: 3.9.0-dev.20200212
Search Terms:
Code
node_modules/@types/dependency/entrypoint.d.tsnode_modules/@types/dependency/internal-types.d.tsnode_modules/@types/dependency/index.d.tsexample.tssrc/app/tsconfig.json{ "compilerOptions": { "declaration": true, } }Expected behavior:
example.d.tsActual behavior:
example.d.tsIt seems that part of the solution could involve having the compiler avoid using relative paths in types (
import("<relativepath>").<typename>) if therelativepathis outside the project.Repro Repo:https://github.com/mheiber/repro-rel-import-inlining
Related Issues:
Issue written with the help of: Robin Ricard (@rricard), Rob Palmer (@robpalme) and Kubilay Kahveci (@mkubilayk)