Skip to content

ts-transform-paths needs updating for TypeScript 4.5+ #37

@Kadeluxe

Description

@Kadeluxe

ts-transform-paths is broken for TypeScript 4.5+.
The reason is that import declarations nodes miss parent node and therefore TS is unable to determine source file of node (compiler/checker.ts, resolveExternalModule function).

I did a quick look and apparently setting newNode.parent to original node .parent fixes it (as you have done for export declarations).
Since I heavily rely on @zerollup/ts-transform-paths in my work, I created @Kadeluxe/ts-transform-paths repo with that fix and some other small changes.

I'm not creating PR here because I don't have much knowledge of TypeScript internals so I can't tell if it's the proper way to fix it. I guess this plugin may need further updating.

UPDATE: since there is no progress on this, I published my fork on NPM: https://www.npmjs.com/package/@kadeluxe/ts-transform-paths
Do npm i @kadeluxe/ts-transform-paths and replace @zerollup/ts-emit-import-alias with @kadeluxe/ts-emit-import-alias in your tsconfig.json. Now it will work.
Also you can switch to different transformer like https://github.com/LeDDGroup/typescript-transform-paths.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions