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

InternalResolutionError does not account for ambient modules #107

Open
andrewbranch opened this issue Oct 16, 2023 · 2 comments
Open

InternalResolutionError does not account for ambient modules #107

andrewbranch opened this issue Oct 16, 2023 · 2 comments
Labels
bug Something isn't working planned I'm going to do this

Comments

@andrewbranch
Copy link
Collaborator

Example: https://arethetypeswrong.github.io/?p=highlight.js%4011.9.0

Using ambient modules in this way should probably be a different problem kind

@andrewbranch andrewbranch added bug Something isn't working planned I'm going to do this labels Oct 16, 2023
@benmccann
Copy link

I think we're getting the same issue for @sveltejs/kit. It's unclear to me if we're actually doing something wrong. If so, it would be helpful if the error message could also suggest some possible fixes as I'm not sure in what other way we should write the types.

@andrewbranch
Copy link
Collaborator Author

Ambient module declarations should only be used to type imports that do not invoke a file-to-file module resolution algorithm at runtime/bundle-time, i.e., environmental built-ins like "fs" or things that a bundler/compiler will strip away no matter the location of the importing file on disk. They should not be used to type imports that will resolve (at runtime/bundle-time) by walking up node_modules. They are not a way to bundle the types for multiple runtime modules into one file like https://github.com/Rich-Harris/dts-buddy tries to do.

arethetypeswrong has a bug here and it will report the wrong (and more severe) kind of problem, but there are so few instances where it’s correct to use an ambient module declaration that it feels likely that SvelteKit is misusing them. When I fix this, I’ll write accompanying docs about the consequences of misusing ambient module declarations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working planned I'm going to do this
Projects
None yet
Development

No branches or pull requests

2 participants