-
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
Typescript fails to resolve module when type definitions are placed outside the root path (with typesVersions) #43133
Labels
Needs Investigation
This issue needs a team member to investigate its status.
Rescheduled
This issue was previously scheduled to an earlier milestone
Milestone
Comments
pedrodurek
changed the title
Typescript fails to resolve module when type definitions are declared outside the root path (with typesVersions)
Typescript fails to resolve module when type definitions are placed outside the root path (with typesVersions)
Mar 8, 2021
RyanCavanaugh
added
the
Needs Investigation
This issue needs a team member to investigate its status.
label
Mar 9, 2021
4 tasks
RyanCavanaugh
added
the
Rescheduled
This issue was previously scheduled to an earlier milestone
label
Jun 18, 2021
As a workaround, adding both
|
This was referenced Feb 14, 2023
RomainMuller
added a commit
to aws/jsii-compiler
that referenced
this issue
Mar 30, 2023
The `typesVersions` directive applies recursively when the TypeScript compiler searches for the appropriate object to load... When attempting to resolve a directory, it will first rewrite that directory according to the typesVersions directive, and then it will rewrite the `index` sub-path within there again, resulting in two distinct rewrites happening within the same resolution. This appears to be a TypeScript bug as reported in microsoft/TypeScript#43133. The work-around is to include a second rewrite candidate that explicitly targets the `*/index.d.ts` sub-path, which makes removes the need for a rewrite when searching down the `index` route. Causes projen/projen#2570
aws-cdk-automation
pushed a commit
to aws/jsii-compiler
that referenced
this issue
Mar 30, 2023
The `typesVersions` directive applies recursively when the TypeScript compiler searches for the appropriate object to load... When attempting to resolve a directory, it will first rewrite that directory according to the typesVersions directive, and then it will rewrite the `index` sub-path within there again, resulting in two distinct rewrites happening within the same resolution. This appears to be a TypeScript bug as reported in microsoft/TypeScript#43133. The work-around is to include a second rewrite candidate that explicitly targets the `*/index.d.ts` sub-path, which removes the need for a rewrite when searching down the `index` route. Causes projen/projen#2570 --- By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license]. [Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0
3 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Needs Investigation
This issue needs a team member to investigate its status.
Rescheduled
This issue was previously scheduled to an earlier milestone
Bug Report
If you have a project with embedded type definitions that are not in root path. i.e.:
src/index.d.ts
andsrc/ts4.1/index.d.ts
, TypeScript fails to resolve this module when using the following approach:It works, if we replace
*
toindex.d.ts
, like this:However, when we replace it with the actual file (
src/ts4.1/index.d.ts
), VS Code sometimes imports the module incorrectly, i.e.:Rather than:
Here you can find some context.
💻 Code
https://github.com/i18next/react-i18next/blob/master/package.json#L7
🙁 Actual behavior
It fails to compile, and fails to auto-import properly.
🙂 Expected behavior
Resolve the module and import it properly.
The text was updated successfully, but these errors were encountered: