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

[BUG] Not all Node Types are imported #29

Open
WilliamABradley opened this issue Apr 3, 2023 · 0 comments
Open

[BUG] Not all Node Types are imported #29

WilliamABradley opened this issue Apr 3, 2023 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@WilliamABradley
Copy link
Contributor

Describe the bug
It appears that @types/node has reference imports that are absolute instead of relative, this means they are thought of as separate packages, and a separate import is attempted for a package that doesn't exist.

Not sure if other packages do this, maybe we can treat absolute with the .d.ts extension as a root import, or other smarts are required.

I resolved the issue myself by extending the sourceResolver and adding:

let uResolved = await super.resolveSourceFile(
  packageName,
  version,
  path
);
if (packageName === "@types/node") {
  // Fix up the reference imports, they seem to be broken
  // Since they are absolute
  uResolved = uResolved?.replaceAll(
    /reference path="/g,
    'reference path="./'
  );
}
return uResolved;

See declaration: https://unpkg.com/@types/[email protected]/index.d.ts

To Reproduce
Import @types/node via versions object, and check our the console/network tab.

Expected behavior
Imports the file correctly.

Screenshots
If applicable, add screenshots to help explain your problem. You can drag image files here to upload them to the issue.

Environment (please complete the following information):

  • OS: MacOS
  • Browser Version: MS Edge 111.0.1661.54
  • monaco-editor-auto-typings Version: 0.4.3

Additional context
Add any other context about the problem here.

@WilliamABradley WilliamABradley added the bug Something isn't working label Apr 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants