diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2022-11-30 18:07:32 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-30 23:07:32 +0000 |
commit | b1e29d1bd09b08bb6d3b307ae5c5c41e0dd012e3 (patch) | |
tree | f65cfbb09dbaf2e32d86b965ee879f6db640f4b3 /cli/tests | |
parent | d1962e07afb3761c85cde90bda751c23c144741f (diff) |
fix(npm): improve package.json exports support for types (#16880)
Diffstat (limited to 'cli/tests')
6 files changed, 30 insertions, 0 deletions
diff --git a/cli/tests/npm_tests.rs b/cli/tests/npm_tests.rs index c845f8f4a..39dd1d549 100644 --- a/cli/tests/npm_tests.rs +++ b/cli/tests/npm_tests.rs @@ -327,6 +327,14 @@ mod npm { exit_code: 0, }); + itest!(types_exports_import_types { + args: "run --check=all npm/types_exports_import_types/main.ts", + output: "npm/types_exports_import_types/main.out", + envs: env_vars_for_npm_tests(), + http_server: true, + exit_code: 0, + }); + itest!(types_no_types_entry { args: "run --check=all npm/types_no_types_entry/main.ts", output: "npm/types_no_types_entry/main.out", diff --git a/cli/tests/testdata/npm/registry/@denotest/types-exports-import-types/1.0.0/dist/main.d.ts b/cli/tests/testdata/npm/registry/@denotest/types-exports-import-types/1.0.0/dist/main.d.ts new file mode 100644 index 000000000..2341a14f0 --- /dev/null +++ b/cli/tests/testdata/npm/registry/@denotest/types-exports-import-types/1.0.0/dist/main.d.ts @@ -0,0 +1 @@ +export function getValue(): 5; diff --git a/cli/tests/testdata/npm/registry/@denotest/types-exports-import-types/1.0.0/dist/main.mjs b/cli/tests/testdata/npm/registry/@denotest/types-exports-import-types/1.0.0/dist/main.mjs new file mode 100644 index 000000000..358b4b09e --- /dev/null +++ b/cli/tests/testdata/npm/registry/@denotest/types-exports-import-types/1.0.0/dist/main.mjs @@ -0,0 +1,3 @@ +export function getValue() { + return 5; +} diff --git a/cli/tests/testdata/npm/registry/@denotest/types-exports-import-types/1.0.0/package.json b/cli/tests/testdata/npm/registry/@denotest/types-exports-import-types/1.0.0/package.json new file mode 100644 index 000000000..202a2c784 --- /dev/null +++ b/cli/tests/testdata/npm/registry/@denotest/types-exports-import-types/1.0.0/package.json @@ -0,0 +1,10 @@ +{ + "name": "@denotest/types-exports-import-types", + "version": "1.0.0", + "exports": { + "node": { + "types": "./dist/main.d.ts", + "import": "./dist/main.mjs" + } + } +} diff --git a/cli/tests/testdata/npm/types_exports_import_types/main.out b/cli/tests/testdata/npm/types_exports_import_types/main.out new file mode 100644 index 000000000..6f6cb8366 --- /dev/null +++ b/cli/tests/testdata/npm/types_exports_import_types/main.out @@ -0,0 +1,4 @@ +Download http://localhost:4545/npm/registry/@denotest/types-exports-import-types +Download http://localhost:4545/npm/registry/@denotest/types-exports-import-types/1.0.0.tgz +Check file://[WILDCARD]/types_exports_import_types/main.ts +5 diff --git a/cli/tests/testdata/npm/types_exports_import_types/main.ts b/cli/tests/testdata/npm/types_exports_import_types/main.ts new file mode 100644 index 000000000..00b69c438 --- /dev/null +++ b/cli/tests/testdata/npm/types_exports_import_types/main.ts @@ -0,0 +1,4 @@ +import { getValue } from "npm:@denotest/types-exports-import-types"; + +const result: 5 = getValue(); +console.log(result); |