Fix references to path-mapped ambient modules in declaration files#32878
Fix references to path-mapped ambient modules in declaration files#32878weswigham merged 2 commits intomicrosoft:masterfrom
Conversation
|
|
||
| //// [index.d.ts] | ||
| /// <reference types="@ts-bug/a" /> | ||
| export declare function b(text: string): import("@ts-bug/a").AText; |
There was a problem hiding this comment.
As an aside, since the import is import("@ts-bug/a"), we don't need the /// <reference types="@ts-bug/a" />, since they refer to the "same" thing (or at least cause the same file to be found and included). However since the import could be something like @ts-bug/a/b (which could be an ambient module in @ts-bug/a), we can't generally elide the reference. A cleanup pass where we remove types directives which exactly match an import somewhere in the file may be pertinent.
andrewbranch
left a comment
There was a problem hiding this comment.
Ah, my old friend moduleSpecifiers.getModuleSpecifier, we meet again.
|
@RyanCavanaugh @DanielRosenwasser wanna have this ported this to 3.6 (since it was in the 3.6 milestone)? |
|
@typescript-bot cherry-pick this into release-3.6 |
|
Hey @weswigham, I've opened #32881 for you. |
🤖 Cherry-pick PR #32878 into release-3.6
Fixes #26863
With this change, we now attempt to use a non-relative reference to a declaration file, if possible, before emitting a relative reference.