-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix references to path-mapped ambient modules in declaration files #32878
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.