Skip to content

InternalResolutionError does not account for ambient modules #107

Open

Description

@andrewbranch

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

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

Activity

  1. benmccann commented on Nov 14, 2023

    @benmccann

    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.

  2. andrewbranch commented on Nov 14, 2023

    @andrewbranch
    CollaboratorAuthor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingplannedI'm going to do this

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions