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 resolving js imports that have same-named ".d.ts" from ts with 'noTypeDefinitions' set to true #113

Merged

Conversation

williamvinogradov
Copy link

Reason:
If .d.ts exists, ts resolve import as the path to the type-definition file by default (instead of the js file).
But if we set the noTypeDefinitions flag to true,
we pass the unresolved import path to the ts.resolveJSModule.

And if we have a type alias:

// tsconfig.json
{
  "compilerOptions": {
    "paths": {
      "@test/*": ["*"]
    }
  }
}

our unresolved import looks like

@test/foo

instead of

<path_to_directory>/foo

Therefore ts cannot resolve this import and fails with an error.

Solution:
Pass to the ts.resolveJSModule resolved path of the import without extension.

Relates to: #112

@mrjoelkemp mrjoelkemp merged commit 956031d into dependents:master Mar 10, 2023
@mrjoelkemp
Copy link
Collaborator

Thanks @williamvinogradov! Released a new patch version with the fix.

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.

2 participants