feat: add the types package of a mapped dependency to the dev dependencies - #509
Merged
Merged
Conversation
…ncies When a remote module is mapped to an npm package, the declaration files the cdn specifies for it (ex. via an `X-TypeScript-Types` header on esm.sh) were dropped, so the output failed to type check with "Could not find a declaration file for module". Now the npm package providing those declarations is added to the dev dependencies of the output package.json. Closes denoland#297 Closes denoland#343
- keep a declaration file in the output when a module imports it directly - only fetch the modules a cdn mapper mapped, so the modules the user mapped themselves are still never downloaded - resolve the types header relative to the module's final url - warn when the type declarations of a mapped module can't be resolved - ignore skypack internal urls, which have a build hash for a version - match declaration files with a query string or other extensions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #297
Closes #343
When a remote module is mapped to an npm package, the declaration files that the cdn specifies for it were dropped, so the output failed to type check:
esm.sh points at the declarations with an
X-TypeScript-Typesheader (https://esm.sh/@types/svg-path-parser@~1.1.6/index.d.ts), so now the package providing them is added to the dev dependencies:{ "dependencies": { "svg-path-parser": "1.1.0" }, "devDependencies": { "@types/svg-path-parser": "~1.1.6" } }The same applies to a declaration file specified with
@deno-types, and the file is no longer emitted into the output when a package provides it.Details:
Verified against the reproductions in both issues:
https://esm.sh/svg-path-parser@1.1.0now type checks, and the react example in #343 emitssetIsEnabled: React.Dispatch<React.SetStateAction<boolean>>instead ofany.