From 52ababc4bf948904092cff54c2ab8b91f6b9b443 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Tue, 23 Jul 2024 20:22:24 -0400 Subject: fix(node): better detection for when to surface node resolution errors (#24653) --- tests/integration/npm_tests.rs | 37 +--------- .../byonm_phantom_dep_res_failure/__test__.jsonc | 13 ++++ .../byonm_phantom_dep_res_failure/bad_import.out | 2 + .../byonm_phantom_dep_res_failure/bad_import.ts | 3 + .../node/byonm_phantom_dep_res_failure/deno.json | 3 + .../byonm_phantom_dep_res_failure/good_import.out | 1 + .../byonm_phantom_dep_res_failure/good_import.ts | 3 + .../node_modules/package/main.js | 1 + .../node_modules/package/package.json | 4 ++ .../byonm_phantom_dep_res_failure/package.json | 2 + .../npm/esm_import_cjs_default/__test__.jsonc | 4 ++ tests/specs/npm/esm_import_cjs_default/main.out | 58 ++++++++++++++++ tests/specs/npm/esm_import_cjs_default/main.ts | 23 +++++++ tests/specs/npm/no_types_cjs/__test__.jsonc | 4 ++ tests/specs/npm/no_types_cjs/main.out | 3 + tests/specs/npm/no_types_cjs/main.ts | 7 ++ .../no_types_in_conditional_exports/__test__.jsonc | 4 ++ .../npm/no_types_in_conditional_exports/main.out | 4 ++ .../npm/no_types_in_conditional_exports/main.ts | 2 + tests/specs/npm/types_general/__test__.jsonc | 5 ++ tests/specs/npm/types_general/main.out | 80 ++++++++++++++++++++++ tests/specs/npm/types_general/main.ts | 27 ++++++++ tests/testdata/npm/esm_import_cjs_default/main.out | 51 -------------- tests/testdata/npm/esm_import_cjs_default/main.ts | 23 ------- tests/testdata/npm/no_types_cjs/main.ts | 7 -- .../npm/no_types_in_conditional_exports/main.out | 4 -- .../npm/no_types_in_conditional_exports/main.ts | 2 - tests/testdata/npm/types/main.out | 71 ------------------- tests/testdata/npm/types/main.ts | 27 -------- 29 files changed, 256 insertions(+), 219 deletions(-) create mode 100644 tests/specs/node/byonm_phantom_dep_res_failure/__test__.jsonc create mode 100644 tests/specs/node/byonm_phantom_dep_res_failure/bad_import.out create mode 100644 tests/specs/node/byonm_phantom_dep_res_failure/bad_import.ts create mode 100644 tests/specs/node/byonm_phantom_dep_res_failure/deno.json create mode 100644 tests/specs/node/byonm_phantom_dep_res_failure/good_import.out create mode 100644 tests/specs/node/byonm_phantom_dep_res_failure/good_import.ts create mode 100644 tests/specs/node/byonm_phantom_dep_res_failure/node_modules/package/main.js create mode 100644 tests/specs/node/byonm_phantom_dep_res_failure/node_modules/package/package.json create mode 100644 tests/specs/node/byonm_phantom_dep_res_failure/package.json create mode 100644 tests/specs/npm/esm_import_cjs_default/__test__.jsonc create mode 100644 tests/specs/npm/esm_import_cjs_default/main.out create mode 100644 tests/specs/npm/esm_import_cjs_default/main.ts create mode 100644 tests/specs/npm/no_types_cjs/__test__.jsonc create mode 100644 tests/specs/npm/no_types_cjs/main.out create mode 100644 tests/specs/npm/no_types_cjs/main.ts create mode 100644 tests/specs/npm/no_types_in_conditional_exports/__test__.jsonc create mode 100644 tests/specs/npm/no_types_in_conditional_exports/main.out create mode 100644 tests/specs/npm/no_types_in_conditional_exports/main.ts create mode 100644 tests/specs/npm/types_general/__test__.jsonc create mode 100644 tests/specs/npm/types_general/main.out create mode 100644 tests/specs/npm/types_general/main.ts delete mode 100644 tests/testdata/npm/esm_import_cjs_default/main.out delete mode 100644 tests/testdata/npm/esm_import_cjs_default/main.ts delete mode 100644 tests/testdata/npm/no_types_cjs/main.ts delete mode 100644 tests/testdata/npm/no_types_in_conditional_exports/main.out delete mode 100644 tests/testdata/npm/no_types_in_conditional_exports/main.ts delete mode 100644 tests/testdata/npm/types/main.out delete mode 100644 tests/testdata/npm/types/main.ts (limited to 'tests') diff --git a/tests/integration/npm_tests.rs b/tests/integration/npm_tests.rs index dba519087..e721633a6 100644 --- a/tests/integration/npm_tests.rs +++ b/tests/integration/npm_tests.rs @@ -15,13 +15,6 @@ use util::TestContextBuilder; // NOTE: See how to make test npm packages at ./testdata/npm/README.md -itest!(esm_import_cjs_default { - args: "run --allow-read --allow-env --quiet --check=all npm/esm_import_cjs_default/main.ts", - output: "npm/esm_import_cjs_default/main.out", - envs: env_vars_for_npm_tests(), - http_server: true, -}); - itest!(cjs_with_deps { args: "run --allow-read --allow-env npm/cjs_with_deps/main.js", output: "npm/cjs_with_deps/main.out", @@ -324,14 +317,6 @@ itest!(check_local { exit_code: 1, }); -itest!(types_general { - args: "check --quiet npm/types/main.ts", - output: "npm/types/main.out", - envs: env_vars_for_npm_tests(), - http_server: true, - exit_code: 1, -}); - itest!(types_ambient_module { args: "check --quiet npm/types_ambient_module/main.ts", output: "npm/types_ambient_module/main.out", @@ -341,27 +326,11 @@ itest!(types_ambient_module { }); itest!(types_ambient_module_import_map { - args: "check --quiet --import-map=npm/types_ambient_module/import_map.json npm/types_ambient_module/main_import_map.ts", - output: "npm/types_ambient_module/main_import_map.out", - envs: env_vars_for_npm_tests(), - http_server: true, - exit_code: 1, - }); - -itest!(no_types_cjs { - args: "check --quiet npm/no_types_cjs/main.ts", - output_str: Some(""), - exit_code: 0, - envs: env_vars_for_npm_tests(), - http_server: true, -}); - -itest!(no_types_in_conditional_exports { - args: "run --check npm/no_types_in_conditional_exports/main.ts", - output: "npm/no_types_in_conditional_exports/main.out", - exit_code: 0, + args: "check --quiet --import-map=npm/types_ambient_module/import_map.json npm/types_ambient_module/main_import_map.ts", + output: "npm/types_ambient_module/main_import_map.out", envs: env_vars_for_npm_tests(), http_server: true, + exit_code: 1, }); itest!(types_entry_value_not_exists { diff --git a/tests/specs/node/byonm_phantom_dep_res_failure/__test__.jsonc b/tests/specs/node/byonm_phantom_dep_res_failure/__test__.jsonc new file mode 100644 index 000000000..35e0a7686 --- /dev/null +++ b/tests/specs/node/byonm_phantom_dep_res_failure/__test__.jsonc @@ -0,0 +1,13 @@ +{ + "tests": { + "bad_import": { + "args": "run bad_import.ts", + "output": "bad_import.out", + "exitCode": 1 + }, + "good_import": { + "args": "run good_import.ts", + "output": "good_import.out" + } + } +} diff --git a/tests/specs/node/byonm_phantom_dep_res_failure/bad_import.out b/tests/specs/node/byonm_phantom_dep_res_failure/bad_import.out new file mode 100644 index 000000000..a524720e3 --- /dev/null +++ b/tests/specs/node/byonm_phantom_dep_res_failure/bad_import.out @@ -0,0 +1,2 @@ +error: [ERR_MODULE_NOT_FOUND] Cannot find module 'file:///[WILDLINE]/node_modules/package/index.js' imported from 'file:///[WILDLINE]/bad_import.ts' + at file:///[WILDLINE]/bad_import.ts:1:16 diff --git a/tests/specs/node/byonm_phantom_dep_res_failure/bad_import.ts b/tests/specs/node/byonm_phantom_dep_res_failure/bad_import.ts new file mode 100644 index 000000000..e20fe1fcf --- /dev/null +++ b/tests/specs/node/byonm_phantom_dep_res_failure/bad_import.ts @@ -0,0 +1,3 @@ +import hi from "package"; + +hi(); diff --git a/tests/specs/node/byonm_phantom_dep_res_failure/deno.json b/tests/specs/node/byonm_phantom_dep_res_failure/deno.json new file mode 100644 index 000000000..6134d86d1 --- /dev/null +++ b/tests/specs/node/byonm_phantom_dep_res_failure/deno.json @@ -0,0 +1,3 @@ +{ + "unstable": ["byonm"] +} diff --git a/tests/specs/node/byonm_phantom_dep_res_failure/good_import.out b/tests/specs/node/byonm_phantom_dep_res_failure/good_import.out new file mode 100644 index 000000000..45b983be3 --- /dev/null +++ b/tests/specs/node/byonm_phantom_dep_res_failure/good_import.out @@ -0,0 +1 @@ +hi diff --git a/tests/specs/node/byonm_phantom_dep_res_failure/good_import.ts b/tests/specs/node/byonm_phantom_dep_res_failure/good_import.ts new file mode 100644 index 000000000..2b17d3e33 --- /dev/null +++ b/tests/specs/node/byonm_phantom_dep_res_failure/good_import.ts @@ -0,0 +1,3 @@ +import hi from "package/main.js"; + +hi(); diff --git a/tests/specs/node/byonm_phantom_dep_res_failure/node_modules/package/main.js b/tests/specs/node/byonm_phantom_dep_res_failure/node_modules/package/main.js new file mode 100644 index 000000000..bc76b8e9e --- /dev/null +++ b/tests/specs/node/byonm_phantom_dep_res_failure/node_modules/package/main.js @@ -0,0 +1 @@ +module.exports = () => console.log('hi'); \ No newline at end of file diff --git a/tests/specs/node/byonm_phantom_dep_res_failure/node_modules/package/package.json b/tests/specs/node/byonm_phantom_dep_res_failure/node_modules/package/package.json new file mode 100644 index 000000000..5723987e9 --- /dev/null +++ b/tests/specs/node/byonm_phantom_dep_res_failure/node_modules/package/package.json @@ -0,0 +1,4 @@ +{ + "name": "package", + "version": "1.0.0" +} \ No newline at end of file diff --git a/tests/specs/node/byonm_phantom_dep_res_failure/package.json b/tests/specs/node/byonm_phantom_dep_res_failure/package.json new file mode 100644 index 000000000..2c63c0851 --- /dev/null +++ b/tests/specs/node/byonm_phantom_dep_res_failure/package.json @@ -0,0 +1,2 @@ +{ +} diff --git a/tests/specs/npm/esm_import_cjs_default/__test__.jsonc b/tests/specs/npm/esm_import_cjs_default/__test__.jsonc new file mode 100644 index 000000000..b2a25914f --- /dev/null +++ b/tests/specs/npm/esm_import_cjs_default/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-read --allow-env --check=all main.ts", + "output": "main.out" +} diff --git a/tests/specs/npm/esm_import_cjs_default/main.out b/tests/specs/npm/esm_import_cjs_default/main.out new file mode 100644 index 000000000..ec7962e5a --- /dev/null +++ b/tests/specs/npm/esm_import_cjs_default/main.out @@ -0,0 +1,58 @@ +[UNORDERED_START] +Download http://localhost:4260/@denotest/esm-import-cjs-default +Download http://localhost:4260/@denotest/cjs-default-export +Download http://localhost:4260/@denotest/cjs-default-export/1.0.0.tgz +Download http://localhost:4260/@denotest/esm-import-cjs-default/1.0.0.tgz +[UNORDERED_END] +Check file:///[WILDLINE]/main.ts +Node esm importing node cjs +=========================== +{ + default: [Function (anonymous)], + named: [Function (anonymous)], + MyClass: [class MyClass] +} +{ default: [Function (anonymous)], named: [Function (anonymous)] } +[Module: null prototype] { + MyClass: [class MyClass], + __esModule: true, + default: { + default: [Function (anonymous)], + named: [Function (anonymous)], + MyClass: [class MyClass] + }, + named: [Function (anonymous)] +} +[Module: null prototype] { + __esModule: true, + default: { default: [Function (anonymous)], named: [Function (anonymous)] }, + named: [Function (anonymous)] +} +=========================== +static method +Deno esm importing node cjs +=========================== +{ + default: [Function (anonymous)], + named: [Function (anonymous)], + MyClass: [class MyClass] +} +[Module: null prototype] { + MyClass: [class MyClass], + __esModule: true, + default: { + default: [Function (anonymous)], + named: [Function (anonymous)], + MyClass: [class MyClass] + }, + named: [Function (anonymous)] +} +=========================== +Deno esm importing node esm +=========================== +[Function: default] +[Module: null prototype] { default: [Function: default] } +=========================== +1 +5 +static method diff --git a/tests/specs/npm/esm_import_cjs_default/main.ts b/tests/specs/npm/esm_import_cjs_default/main.ts new file mode 100644 index 000000000..f9c3280e5 --- /dev/null +++ b/tests/specs/npm/esm_import_cjs_default/main.ts @@ -0,0 +1,23 @@ +// @ts-check +import cjsDefault, { + MyClass as MyCjsClass, +} from "npm:@denotest/cjs-default-export"; +import * as cjsNamespace from "npm:@denotest/cjs-default-export"; +import esmDefault from "npm:@denotest/esm-import-cjs-default"; +import * as esmNamespace from "npm:@denotest/esm-import-cjs-default"; + +console.log("Deno esm importing node cjs"); +console.log("==========================="); +console.log(cjsDefault); +console.log(cjsNamespace); +console.log("==========================="); + +console.log("Deno esm importing node esm"); +console.log("==========================="); +console.log(esmDefault); +console.log(esmNamespace); +console.log("==========================="); + +console.log(cjsDefault.default()); +console.log(esmDefault()); +console.log(MyCjsClass.someStaticMethod()); diff --git a/tests/specs/npm/no_types_cjs/__test__.jsonc b/tests/specs/npm/no_types_cjs/__test__.jsonc new file mode 100644 index 000000000..de0339cfb --- /dev/null +++ b/tests/specs/npm/no_types_cjs/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "check main.ts", + "output": "main.out" +} diff --git a/tests/specs/npm/no_types_cjs/main.out b/tests/specs/npm/no_types_cjs/main.out new file mode 100644 index 000000000..4747a9a32 --- /dev/null +++ b/tests/specs/npm/no_types_cjs/main.out @@ -0,0 +1,3 @@ +Download http://localhost:4260/@denotest/no-types-cjs +Download http://localhost:4260/@denotest/no-types-cjs/1.0.0.tgz +Check file:///[WILDLINE]/no_types_cjs/main.ts diff --git a/tests/specs/npm/no_types_cjs/main.ts b/tests/specs/npm/no_types_cjs/main.ts new file mode 100644 index 000000000..32458e839 --- /dev/null +++ b/tests/specs/npm/no_types_cjs/main.ts @@ -0,0 +1,7 @@ +import mod from "npm:@denotest/no-types-cjs"; + +// it actually returns a `number` and has that in its +// jsdocs, but the jsdocs should not have been resolved so +// this should type check just fine +const value: string = mod(); +console.log(value); diff --git a/tests/specs/npm/no_types_in_conditional_exports/__test__.jsonc b/tests/specs/npm/no_types_in_conditional_exports/__test__.jsonc new file mode 100644 index 000000000..8955fcda2 --- /dev/null +++ b/tests/specs/npm/no_types_in_conditional_exports/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --check main.ts", + "output": "main.out" +} diff --git a/tests/specs/npm/no_types_in_conditional_exports/main.out b/tests/specs/npm/no_types_in_conditional_exports/main.out new file mode 100644 index 000000000..46c583234 --- /dev/null +++ b/tests/specs/npm/no_types_in_conditional_exports/main.out @@ -0,0 +1,4 @@ +Download http://localhost:4260/@denotest/no-types-in-conditional-exports +Download http://localhost:4260/@denotest/no-types-in-conditional-exports/1.0.0.tgz +Check [WILDCARD]npm/no_types_in_conditional_exports/main.ts +{ foo: "bar" } diff --git a/tests/specs/npm/no_types_in_conditional_exports/main.ts b/tests/specs/npm/no_types_in_conditional_exports/main.ts new file mode 100644 index 000000000..7ec2f18fd --- /dev/null +++ b/tests/specs/npm/no_types_in_conditional_exports/main.ts @@ -0,0 +1,2 @@ +import foo from "npm:@denotest/no-types-in-conditional-exports@1.0.0"; +console.log(foo); diff --git a/tests/specs/npm/types_general/__test__.jsonc b/tests/specs/npm/types_general/__test__.jsonc new file mode 100644 index 000000000..a991c6eed --- /dev/null +++ b/tests/specs/npm/types_general/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "check main.ts", + "output": "main.out", + "exitCode": 1 +} diff --git a/tests/specs/npm/types_general/main.out b/tests/specs/npm/types_general/main.out new file mode 100644 index 000000000..ffba4f84d --- /dev/null +++ b/tests/specs/npm/types_general/main.out @@ -0,0 +1,80 @@ +[UNORDERED_START] +Download http://localhost:4260/@denotest/types +Download http://localhost:4260/@denotest/types_imported +Download http://localhost:4260/@denotest/types-exports-subpaths +Download http://localhost:4260/@denotest/types_imported/1.0.0.tgz +Download http://localhost:4260/@denotest/types-exports-subpaths/1.0.0.tgz +Download http://localhost:4260/@denotest/types/1.0.0.tgz +[UNORDERED_END] +Check file:///[WILDLINE]/main.ts +error: TS2322 [ERROR]: Type 'number' is not assignable to type 'string'. + bar: 1, + ~~~ + at [WILDCARD]/main.ts:[WILDCARD] + + The expected type comes from property 'bar' which is declared here on type 'Foobar' + bar: string; + ~~~ + at [WILDCARD]/@denotest/types_imported/1.0.0/subpath.d.ts:3:5 + +TS2322 [ERROR]: Type 'number' is not assignable to type 'string'. + prop: 1, + ~~~~ + at [WILDCARD]/main.ts:[WILDCARD] + + The expected type comes from property 'prop' which is declared here on type 'SomeInterface' + prop: string; + ~~~~ + at [WILDCARD]/@denotest/types_imported/1.0.0/index.d.ts:2:5 + +TS2322 [ERROR]: Type 'string' is not assignable to type 'number'. + prop2: "asdf", + ~~~~~ + at [WILDCARD]/main.ts:[WILDCARD] + + The expected type comes from property 'prop2' which is declared here on type 'SomeInterface' + prop2: number; + ~~~~~ + at [WILDCARD]/@denotest/types_imported/1.0.0/index.d.ts:3:5 + +TS2322 [ERROR]: Type 'number' is not assignable to type 'string'. + fizz: 1, + ~~~~ + at [WILDCARD]/main.ts:[WILDCARD] + + The expected type comes from property 'fizz' which is declared here on type 'Fizzbuzz' + fizz: string; + ~~~~ + at [WILDCARD]/@denotest/types/1.0.0/index.d.ts:2:3 + +TS2322 [ERROR]: Type 'number' is not assignable to type 'string'. + buzz: 2, + ~~~~ + at [WILDCARD]/main.ts:[WILDCARD] + + The expected type comes from property 'buzz' which is declared here on type 'Fizzbuzz' + buzz: string; + ~~~~ + at [WILDCARD]/@denotest/types/1.0.0/index.d.ts:3:3 + +TS2322 [ERROR]: Type '5' is not assignable to type '"test1"'. +const valueA: "test1" = getClient(); + ~~~~~~ + at [WILDCARD]/main.ts:[WILDCARD] + +TS2322 [ERROR]: Type '"import"' is not assignable to type '"test2"'. +const valueB: "test2" = entryImport(); + ~~~~~~ + at [WILDCARD]/main.ts:[WILDCARD] + +TS2322 [ERROR]: Type '12' is not assignable to type '"test3"'. +const valueC: "test3" = entryA(); + ~~~~~~ + at [WILDCARD]/main.ts:[WILDCARD] + +TS2322 [ERROR]: Type '"types"' is not assignable to type '"test4"'. +const valueD: "test4" = entryTypes(); + ~~~~~~ + at file:///[WILDCARD]/main.ts:[WILDCARD] + +Found 9 errors. diff --git a/tests/specs/npm/types_general/main.ts b/tests/specs/npm/types_general/main.ts new file mode 100644 index 000000000..ae420f6d6 --- /dev/null +++ b/tests/specs/npm/types_general/main.ts @@ -0,0 +1,27 @@ +import type { Fizzbuzz } from "npm:@denotest/types"; +import type { SomeInterface } from "npm:@denotest/types_imported"; +import type { Foobar as FooInterface } from "npm:@denotest/types_imported/subpath"; +import { getClient } from "npm:@denotest/types-exports-subpaths/client"; +import { entryImport } from "npm:@denotest/types-exports-subpaths/entry-import"; +import { entryA } from "npm:@denotest/types-exports-subpaths/entry-a"; +import { entryTypes } from "npm:@denotest/types-exports-subpaths/entry-types-last-no-declaration-before"; + +const foobar: FooInterface = { + foo: "foo", + bar: 1, +}; + +const i: SomeInterface = { + prop: 1, + prop2: "asdf", +}; + +const fizzbuzz: Fizzbuzz = { + fizz: 1, + buzz: 2, +}; + +const valueA: "test1" = getClient(); +const valueB: "test2" = entryImport(); +const valueC: "test3" = entryA(); +const valueD: "test4" = entryTypes(); diff --git a/tests/testdata/npm/esm_import_cjs_default/main.out b/tests/testdata/npm/esm_import_cjs_default/main.out deleted file mode 100644 index 0f6a61e34..000000000 --- a/tests/testdata/npm/esm_import_cjs_default/main.out +++ /dev/null @@ -1,51 +0,0 @@ -Node esm importing node cjs -=========================== -{ - default: [Function (anonymous)], - named: [Function (anonymous)], - MyClass: [class MyClass] -} -{ default: [Function (anonymous)], named: [Function (anonymous)] } -[Module: null prototype] { - MyClass: [class MyClass], - __esModule: true, - default: { - default: [Function (anonymous)], - named: [Function (anonymous)], - MyClass: [class MyClass] - }, - named: [Function (anonymous)] -} -[Module: null prototype] { - __esModule: true, - default: { default: [Function (anonymous)], named: [Function (anonymous)] }, - named: [Function (anonymous)] -} -=========================== -static method -Deno esm importing node cjs -=========================== -{ - default: [Function (anonymous)], - named: [Function (anonymous)], - MyClass: [class MyClass] -} -[Module: null prototype] { - MyClass: [class MyClass], - __esModule: true, - default: { - default: [Function (anonymous)], - named: [Function (anonymous)], - MyClass: [class MyClass] - }, - named: [Function (anonymous)] -} -=========================== -Deno esm importing node esm -=========================== -[Function: default] -[Module: null prototype] { default: [Function: default] } -=========================== -1 -5 -static method diff --git a/tests/testdata/npm/esm_import_cjs_default/main.ts b/tests/testdata/npm/esm_import_cjs_default/main.ts deleted file mode 100644 index f9c3280e5..000000000 --- a/tests/testdata/npm/esm_import_cjs_default/main.ts +++ /dev/null @@ -1,23 +0,0 @@ -// @ts-check -import cjsDefault, { - MyClass as MyCjsClass, -} from "npm:@denotest/cjs-default-export"; -import * as cjsNamespace from "npm:@denotest/cjs-default-export"; -import esmDefault from "npm:@denotest/esm-import-cjs-default"; -import * as esmNamespace from "npm:@denotest/esm-import-cjs-default"; - -console.log("Deno esm importing node cjs"); -console.log("==========================="); -console.log(cjsDefault); -console.log(cjsNamespace); -console.log("==========================="); - -console.log("Deno esm importing node esm"); -console.log("==========================="); -console.log(esmDefault); -console.log(esmNamespace); -console.log("==========================="); - -console.log(cjsDefault.default()); -console.log(esmDefault()); -console.log(MyCjsClass.someStaticMethod()); diff --git a/tests/testdata/npm/no_types_cjs/main.ts b/tests/testdata/npm/no_types_cjs/main.ts deleted file mode 100644 index 32458e839..000000000 --- a/tests/testdata/npm/no_types_cjs/main.ts +++ /dev/null @@ -1,7 +0,0 @@ -import mod from "npm:@denotest/no-types-cjs"; - -// it actually returns a `number` and has that in its -// jsdocs, but the jsdocs should not have been resolved so -// this should type check just fine -const value: string = mod(); -console.log(value); diff --git a/tests/testdata/npm/no_types_in_conditional_exports/main.out b/tests/testdata/npm/no_types_in_conditional_exports/main.out deleted file mode 100644 index 46c583234..000000000 --- a/tests/testdata/npm/no_types_in_conditional_exports/main.out +++ /dev/null @@ -1,4 +0,0 @@ -Download http://localhost:4260/@denotest/no-types-in-conditional-exports -Download http://localhost:4260/@denotest/no-types-in-conditional-exports/1.0.0.tgz -Check [WILDCARD]npm/no_types_in_conditional_exports/main.ts -{ foo: "bar" } diff --git a/tests/testdata/npm/no_types_in_conditional_exports/main.ts b/tests/testdata/npm/no_types_in_conditional_exports/main.ts deleted file mode 100644 index 7ec2f18fd..000000000 --- a/tests/testdata/npm/no_types_in_conditional_exports/main.ts +++ /dev/null @@ -1,2 +0,0 @@ -import foo from "npm:@denotest/no-types-in-conditional-exports@1.0.0"; -console.log(foo); diff --git a/tests/testdata/npm/types/main.out b/tests/testdata/npm/types/main.out deleted file mode 100644 index de1f2c145..000000000 --- a/tests/testdata/npm/types/main.out +++ /dev/null @@ -1,71 +0,0 @@ -error: TS2322 [ERROR]: Type 'number' is not assignable to type 'string'. - bar: 1, - ~~~ - at [WILDCARD]/npm/types/main.ts:[WILDCARD] - - The expected type comes from property 'bar' which is declared here on type 'Foobar' - bar: string; - ~~~ - at [WILDCARD]/@denotest/types_imported/1.0.0/subpath.d.ts:3:5 - -TS2322 [ERROR]: Type 'number' is not assignable to type 'string'. - prop: 1, - ~~~~ - at [WILDCARD]/npm/types/main.ts:[WILDCARD] - - The expected type comes from property 'prop' which is declared here on type 'SomeInterface' - prop: string; - ~~~~ - at [WILDCARD]/@denotest/types_imported/1.0.0/index.d.ts:2:5 - -TS2322 [ERROR]: Type 'string' is not assignable to type 'number'. - prop2: "asdf", - ~~~~~ - at [WILDCARD]/npm/types/main.ts:[WILDCARD] - - The expected type comes from property 'prop2' which is declared here on type 'SomeInterface' - prop2: number; - ~~~~~ - at [WILDCARD]/@denotest/types_imported/1.0.0/index.d.ts:3:5 - -TS2322 [ERROR]: Type 'number' is not assignable to type 'string'. - fizz: 1, - ~~~~ - at [WILDCARD]/npm/types/main.ts:[WILDCARD] - - The expected type comes from property 'fizz' which is declared here on type 'Fizzbuzz' - fizz: string; - ~~~~ - at [WILDCARD]/@denotest/types/1.0.0/index.d.ts:2:3 - -TS2322 [ERROR]: Type 'number' is not assignable to type 'string'. - buzz: 2, - ~~~~ - at [WILDCARD]/npm/types/main.ts:[WILDCARD] - - The expected type comes from property 'buzz' which is declared here on type 'Fizzbuzz' - buzz: string; - ~~~~ - at [WILDCARD]/@denotest/types/1.0.0/index.d.ts:3:3 - -TS2322 [ERROR]: Type '5' is not assignable to type '"test1"'. -const valueA: "test1" = getClient(); - ~~~~~~ - at [WILDCARD]/npm/types/main.ts:[WILDCARD] - -TS2322 [ERROR]: Type '"import"' is not assignable to type '"test2"'. -const valueB: "test2" = entryImport(); - ~~~~~~ - at [WILDCARD]/types/main.ts:[WILDCARD] - -TS2322 [ERROR]: Type '12' is not assignable to type '"test3"'. -const valueC: "test3" = entryA(); - ~~~~~~ - at [WILDCARD]/types/main.ts:[WILDCARD] - -TS2322 [ERROR]: Type '"types"' is not assignable to type '"test4"'. -const valueD: "test4" = entryTypes(); - ~~~~~~ - at file:///[WILDCARD]/types/main.ts:[WILDCARD] - -Found 9 errors. diff --git a/tests/testdata/npm/types/main.ts b/tests/testdata/npm/types/main.ts deleted file mode 100644 index ae420f6d6..000000000 --- a/tests/testdata/npm/types/main.ts +++ /dev/null @@ -1,27 +0,0 @@ -import type { Fizzbuzz } from "npm:@denotest/types"; -import type { SomeInterface } from "npm:@denotest/types_imported"; -import type { Foobar as FooInterface } from "npm:@denotest/types_imported/subpath"; -import { getClient } from "npm:@denotest/types-exports-subpaths/client"; -import { entryImport } from "npm:@denotest/types-exports-subpaths/entry-import"; -import { entryA } from "npm:@denotest/types-exports-subpaths/entry-a"; -import { entryTypes } from "npm:@denotest/types-exports-subpaths/entry-types-last-no-declaration-before"; - -const foobar: FooInterface = { - foo: "foo", - bar: 1, -}; - -const i: SomeInterface = { - prop: 1, - prop2: "asdf", -}; - -const fizzbuzz: Fizzbuzz = { - fizz: 1, - buzz: 2, -}; - -const valueA: "test1" = getClient(); -const valueB: "test2" = entryImport(); -const valueC: "test3" = entryA(); -const valueD: "test4" = entryTypes(); -- cgit v1.2.3