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:
David Sherret 2024-03-13 22:37:56 -04:00 committed by GitHub
parent 6f5a86ce51
commit bc782cee98
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 226 additions and 81 deletions

View 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);
}
}