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

Associate import map @types/<entry-name> entry as types for <entry-name>? #292

Closed
dsherret opened this issue Sep 11, 2023 · 1 comment
Closed

Comments

@dsherret
Copy link
Member

dsherret commented Sep 11, 2023

It's annoying to have to specify stuff like // @deno-types="..." /> above an import (ex. for a npm:@types/... package) and sometimes it's not possible to specify it (ex. with jsxImportSource: denoland/deno#18203).

Perhaps for any import map entry, deno_graph should try to resolve a corresponding @types/<entry-name> when resolving the types of a module. For example:

// deno.json
{
  // ugh, import maps are painful
  "imports": {
    "react": "npm:react@18",
    "react/": "npm:/react@18/",
    "@types/react": "npm:@types/react@18",
    "@types/react/": "npm:/@types/react@18/",
  }
}

Then when a user imports react or react/jsx-server this would get the corresponding types.

This would also not be npm specific and allow for mapping to non-npm types like:

{
  "imports": {
    "react": "npm:react@18",
    "react/": "npm:/react@18/",
    "@types/react": "./@types/react@18/mod.d.ts",
    "@types/react/": "./@types/react@18/",
  }
}

Import map unfurling

This introduces some complexities when unfurling import maps, but I don't believe it would be too bad because we could inject a // @deno-types="..." comment above the import/export.

@dsherret
Copy link
Member Author

I'm going to close this issue because it just adds additional complexity.

@dsherret dsherret closed this as not planned Won't fix, can't repro, duplicate, stale Sep 11, 2023
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

No branches or pull requests

1 participant