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

Make specifier generation from export map information conditional on module resolution mode #46670

Conversation

weswigham
Copy link
Member

Fixes #46659

This fixes the regression on our part in moduleResolution: node, however rxjs does legitimately have the problem that their types aren't directly visible in their export map, which makes locating a valid specifier for them when export maps are respected rather difficult.

@typescript-bot typescript-bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Nov 3, 2021
}
if (packageJsonContent.exports) {
return { moduleFileToTry: path, blockedByExports: true };
if (getEmitModuleResolutionKind(options) === ModuleResolutionKind.Node12 || getEmitModuleResolutionKind(options) === ModuleResolutionKind.NodeNext) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made the whole of the exports map logic conditional - I could just make the failure modes conditional, but then we might make some specifiers that won't roundtrip through declaration emit (because we use an export map that we won't read in when we build the program), so this is probably better.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think being symmetrical is the right call.

@DanielRosenwasser
Copy link
Member

@typescript-bot cherry-pick this to release-4.5

@typescript-bot
Copy link
Collaborator

typescript-bot commented Nov 3, 2021

Heya @DanielRosenwasser, I've started to run the task to cherry-pick this into release-4.5 on this PR at 615a82c. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

Hey @DanielRosenwasser, I've opened #46671 for you.

typescript-bot pushed a commit to typescript-bot/TypeScript that referenced this pull request Nov 3, 2021
Component commits:
615a82c Make specifier generation from export map information conditional on module resolution mode
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.

however rxjs does legitimately have the problem that their types aren't directly visible in their export map, which makes locating a valid specifier for them when export maps are respected rather difficult.

Yeah, my understanding is that it’s fully expected that the layout of RxJS (export map not mentioning types and types in a completely different directory) means it’s basically unusable under the new resolution modes—they either need to move their types to be colocated with their JS or add a "types" condition to their export map.

@andrewbranch andrewbranch merged commit d53630f into microsoft:main Nov 3, 2021
DanielRosenwasser pushed a commit that referenced this pull request Nov 5, 2021
Component commits:
615a82c Make specifier generation from export map information conditional on module resolution mode

Co-authored-by: Wesley Wigham <t-weswig@microsoft.com>
mprobst pushed a commit to mprobst/TypeScript that referenced this pull request Jan 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Milestone Bug PRs that fix a bug with a specific milestone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

v4.5 regression: The inferred type of '…' cannot be named without a reference to '…'
4 participants