Skip to content
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

Merged
merged 2 commits into from
Aug 13, 2019

Conversation

weswigham
Copy link
Member

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.


//// [index.d.ts]
/// <reference types="@ts-bug/a" />
export declare function b(text: string): import("@ts-bug/a").AText;
Copy link
Member Author

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.

Copy link
Member

@andrewbranch andrewbranch left a 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.

@weswigham weswigham merged commit 602966b into microsoft:master Aug 13, 2019
@weswigham weswigham deleted the relative-refs-monorepo branch August 13, 2019 23:34
@weswigham
Copy link
Member Author

weswigham commented Aug 13, 2019

@RyanCavanaugh @DanielRosenwasser wanna have this ported this to 3.6 (since it was in the 3.6 milestone)?

@weswigham
Copy link
Member Author

@typescript-bot cherry-pick this into release-3.6

@typescript-bot
Copy link
Collaborator

Hey @weswigham, I've opened #32881 for you.

typescript-bot pushed a commit to typescript-bot/TypeScript that referenced this pull request Aug 13, 2019
Component commits:
c78c88f Fix references to path-mapped ambient modules in declaration files

48a1fc3 Fix lint
DanielRosenwasser added a commit that referenced this pull request Aug 13, 2019
🤖 Cherry-pick PR #32878 into release-3.6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Relative reference in generated .d.ts file in a monorepo
3 participants