mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
fix(node): resolve types via package.json for directory import (#22878)
Does a package resolve when resolving types for a directory (copying the behaviour that typescript does).
This commit is contained in:
parent
6f5a86ce51
commit
bc782cee98
9 changed files with 226 additions and 81 deletions
18
tests/specs/npm/check_pkg_json_import/main.ts
Normal file
18
tests/specs/npm/check_pkg_json_import/main.ts
Normal file
|
@ -0,0 +1,18 @@
|
|||
import { createContext } from "npm:@denotest/types-pkg-json-import";
|
||||
import { useContext } from "npm:@denotest/types-pkg-json-import/hooks";
|
||||
|
||||
export interface Foo {
|
||||
foo: string;
|
||||
}
|
||||
|
||||
export const CTX = createContext<Foo | undefined>(undefined);
|
||||
|
||||
function unwrap(foo: Foo) {}
|
||||
|
||||
export function useCSP() {
|
||||
const foo = useContext(CTX);
|
||||
// previously this was erroring
|
||||
if (foo) {
|
||||
unwrap(foo);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue