You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Typescript ignores typings when using tsconfig.json paths #17583
If you have .d.ts files available, why are you re-mapping to the .js file which has no type information associated with it? That's why it's not working the way you expect.
In fact, why are you even using paths if you have the @types package available? When targeting commonjs (or using nodejs for your moduleResolution strategy) the .d.ts files should automatically get picked up.
I do understand. The problem is, that I am using it in the context of an angular4 project using angular-cli. Angular-CLI does not support aliasing or at least only using the information from paths (See angular/angular-cli#6282).
But to use fabric.js with import I need to use a different file than the one stated in the package.jsons main field or the typings from @types/fabric won't fit. My hope was that with paths I can target the correct JavaScript file and I expected it to leave the connection to the typings intact as it was even suggested from the angular-cli team.
I somehow thought that it might be a bug with tsc but thinking at it again: paths only tells tsc where to look for the typings at it does not alter the imports itself. So no wonder it doesn't work as I expected it.
Is there a way to use paths and still have the type information available or at least attach it manually? I tried adding ../node_modules/@types/fabric to the fabric entry in paths but that didn't work (desperate attempt).
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.
Activity
DanielRosenwasser commentedon Aug 3, 2017
If you have
.d.tsfiles available, why are you re-mapping to the.jsfile which has no type information associated with it? That's why it's not working the way you expect.In fact, why are you even using
pathsif you have the@typespackage available? When targetingcommonjs(or usingnodejsfor yourmoduleResolutionstrategy) the.d.tsfiles should automatically get picked up.WoMayr commentedon Aug 3, 2017
I do understand. The problem is, that I am using it in the context of an angular4 project using angular-cli. Angular-CLI does not support aliasing or at least only using the information from
paths(See angular/angular-cli#6282).But to use fabric.js with
importI need to use a different file than the one stated in thepackage.jsonsmainfield or the typings from@types/fabricwon't fit. My hope was that withpathsI can target the correct JavaScript file and I expected it to leave the connection to the typings intact as it was even suggested from the angular-cli team.I somehow thought that it might be a bug with tsc but thinking at it again:
pathsonly tells tsc where to look for the typings at it does not alter the imports itself. So no wonder it doesn't work as I expected it.Is there a way to use
pathsand still have the type information available or at least attach it manually? I tried adding../node_modules/@types/fabricto thefabricentry inpathsbut that didn't work (desperate attempt).mhegazy commentedon Aug 17, 2017
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.