diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2024-03-13 22:37:56 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-13 22:37:56 -0400 |
commit | bc782cee98096d2562d87c7a0b15051b6d0d6628 (patch) | |
tree | 34895fe5b4006d894bfd0d61d9d5bb91e3ededc4 /tests/specs/npm/check_pkg_json_import | |
parent | 6f5a86ce5166440980a9100db5051452e9734fa6 (diff) |
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).
Diffstat (limited to 'tests/specs/npm/check_pkg_json_import')
-rw-r--r-- | tests/specs/npm/check_pkg_json_import/__test__.json | 5 | ||||
-rw-r--r-- | tests/specs/npm/check_pkg_json_import/main.out | 3 | ||||
-rw-r--r-- | tests/specs/npm/check_pkg_json_import/main.ts | 18 |
3 files changed, 26 insertions, 0 deletions
diff --git a/tests/specs/npm/check_pkg_json_import/__test__.json b/tests/specs/npm/check_pkg_json_import/__test__.json new file mode 100644 index 000000000..ce8e53280 --- /dev/null +++ b/tests/specs/npm/check_pkg_json_import/__test__.json @@ -0,0 +1,5 @@ +{ + "base": "npm", + "args": "check --all main.ts", + "output": "main.out" +} diff --git a/tests/specs/npm/check_pkg_json_import/main.out b/tests/specs/npm/check_pkg_json_import/main.out new file mode 100644 index 000000000..1f436e613 --- /dev/null +++ b/tests/specs/npm/check_pkg_json_import/main.out @@ -0,0 +1,3 @@ +Download http://localhost:4545/npm/registry/@denotest/types-pkg-json-import +Download http://localhost:4545/npm/registry/@denotest/types-pkg-json-import/1.0.0.tgz +Check file:///[WILDLINE]/main.ts diff --git a/tests/specs/npm/check_pkg_json_import/main.ts b/tests/specs/npm/check_pkg_json_import/main.ts new file mode 100644 index 000000000..72b887735 --- /dev/null +++ b/tests/specs/npm/check_pkg_json_import/main.ts @@ -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); + } +} |