fix: import a declaration file package by the name it provides types for - #511
Merged
Merged
Conversation
TypeScript errors when an `@types/` package is imported directly (TS6137), so emit the name of the package it provides the declarations for instead (ex. `@types/unist` -> `unist`). Closes denoland#457 Closes denoland#402
- move the helper to the bottom with the other private helpers - add unit tests and an end to end project that type checks the output - document the behavior on the mapping option
…pecifier # Conflicts: # rs-lib/src/lib.rs
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 #457
Closes #402
A deno.json mapping a specifier to a types only package:
{ "imports": { "unist": "npm:@types/unist@3.0.3" } }...emitted
import type { Node } from "@types/unist", which TypeScript rejects:Now the name of the package the declarations are for is emitted instead (
unist), which is how TypeScript resolves an@types/package. The DefinitelyTyped scope encoding is undone as well, so@types/babel__coreis imported as@babel/core. The package.json dependency keeps the real package name.Added
tests/types_package_project, which type checks the output, since that's what the issues report failing.