From 0fcfb6d8024104314fd02c0ffac460a9415b7ee9 Mon Sep 17 00:00:00 2001 From: Julian Grinblat Date: Mon, 13 Jun 2022 18:26:32 +0900 Subject: [PATCH 1/5] Add support for nodenext moduleResolution --- readme.md | 4 ++-- source/lib/config.ts | 16 ++++++++++--- .../node16-from-package-json/index.d.ts | 3 +++ .../node16-from-package-json/index.js | 1 + .../node16-from-package-json/index.test-d.ts | 4 ++++ .../node16-from-package-json/package.json | 9 +++++++ .../node16-from-tsconfig-json/index.d.ts | 3 +++ .../node16-from-tsconfig-json/index.js | 1 + .../node16-from-tsconfig-json/index.test-d.ts | 4 ++++ .../node16-from-tsconfig-json/package.json | 4 ++++ .../node16-from-tsconfig-json/tsconfig.json | 5 ++++ .../nodenext-from-package-json/index.d.ts | 3 +++ .../nodenext-from-package-json/index.js | 1 + .../index.test-d.ts | 4 ++++ .../nodenext-from-package-json/package.json | 9 +++++++ .../nodenext-from-tsconfig-json/index.d.ts | 3 +++ .../nodenext-from-tsconfig-json/index.js | 1 + .../index.test-d.ts | 4 ++++ .../nodenext-from-tsconfig-json/package.json | 4 ++++ .../nodenext-from-tsconfig-json/tsconfig.json | 5 ++++ source/test/test.ts | 24 +++++++++++++++++++ 21 files changed, 107 insertions(+), 5 deletions(-) create mode 100644 source/test/fixtures/module-resolution/node16-from-package-json/index.d.ts create mode 100644 source/test/fixtures/module-resolution/node16-from-package-json/index.js create mode 100644 source/test/fixtures/module-resolution/node16-from-package-json/index.test-d.ts create mode 100644 source/test/fixtures/module-resolution/node16-from-package-json/package.json create mode 100644 source/test/fixtures/module-resolution/node16-from-tsconfig-json/index.d.ts create mode 100644 source/test/fixtures/module-resolution/node16-from-tsconfig-json/index.js create mode 100644 source/test/fixtures/module-resolution/node16-from-tsconfig-json/index.test-d.ts create mode 100644 source/test/fixtures/module-resolution/node16-from-tsconfig-json/package.json create mode 100644 source/test/fixtures/module-resolution/node16-from-tsconfig-json/tsconfig.json create mode 100644 source/test/fixtures/module-resolution/nodenext-from-package-json/index.d.ts create mode 100644 source/test/fixtures/module-resolution/nodenext-from-package-json/index.js create mode 100644 source/test/fixtures/module-resolution/nodenext-from-package-json/index.test-d.ts create mode 100644 source/test/fixtures/module-resolution/nodenext-from-package-json/package.json create mode 100644 source/test/fixtures/module-resolution/nodenext-from-tsconfig-json/index.d.ts create mode 100644 source/test/fixtures/module-resolution/nodenext-from-tsconfig-json/index.js create mode 100644 source/test/fixtures/module-resolution/nodenext-from-tsconfig-json/index.test-d.ts create mode 100644 source/test/fixtures/module-resolution/nodenext-from-tsconfig-json/package.json create mode 100644 source/test/fixtures/module-resolution/nodenext-from-tsconfig-json/tsconfig.json diff --git a/readme.md b/readme.md index bcf5fc39..86996002 100644 --- a/readme.md +++ b/readme.md @@ -136,7 +136,7 @@ By default, `tsd` applies the following configuration: "lib": ["es2017"], "module": "commonjs", // The following option is set and is not overridable: - "moduleResolution": "node" + "moduleResolution": "node" | "node16" | "nodenext" } ``` @@ -153,7 +153,7 @@ These options will be overridden if a `tsconfig.json` file is found in your proj } ``` -*Default options will apply if you don't override them explicitly.* You can't override the `moduleResolution` option. +*Default options will apply if you don't override them explicitly.* You can't override the `moduleResolution` option. `moduleResolution` is set to `nodenext` if `module` is `nodenext`, `node16` if `module` is `node16` or `node` otherwise. ## Assertions diff --git a/source/lib/config.ts b/source/lib/config.ts index a57af9b4..bbd88435 100644 --- a/source/lib/config.ts +++ b/source/lib/config.ts @@ -27,6 +27,11 @@ export default (pkg: PackageJsonWithTsdConfig, cwd: string): Config => { cwd ); + const combinedCompilerOptions = { + ...tsConfigCompilerOptions, + ...packageJsonCompilerOptions, + }; + return { directory: 'test-d', ...pkgConfig, @@ -37,9 +42,14 @@ export default (pkg: PackageJsonWithTsdConfig, cwd: string): Config => { module: ModuleKind.CommonJS, target: ScriptTarget.ES2017, esModuleInterop: true, - ...tsConfigCompilerOptions, - ...packageJsonCompilerOptions, - moduleResolution: ModuleResolutionKind.NodeJs, + ...combinedCompilerOptions, + moduleResolution: combinedCompilerOptions.module === undefined ? + ModuleResolutionKind.NodeJs : + combinedCompilerOptions.module === ModuleKind.NodeNext ? + ModuleResolutionKind.NodeNext : + combinedCompilerOptions.module === ModuleKind.Node16 ? + ModuleResolutionKind.Node16 : + ModuleResolutionKind.NodeJs, skipLibCheck: false } }; diff --git a/source/test/fixtures/module-resolution/node16-from-package-json/index.d.ts b/source/test/fixtures/module-resolution/node16-from-package-json/index.d.ts new file mode 100644 index 00000000..eb851a2b --- /dev/null +++ b/source/test/fixtures/module-resolution/node16-from-package-json/index.d.ts @@ -0,0 +1,3 @@ +declare const foo: string; + +export default foo; diff --git a/source/test/fixtures/module-resolution/node16-from-package-json/index.js b/source/test/fixtures/module-resolution/node16-from-package-json/index.js new file mode 100644 index 00000000..2aac3ab1 --- /dev/null +++ b/source/test/fixtures/module-resolution/node16-from-package-json/index.js @@ -0,0 +1 @@ +module.exports.default = "foo"; diff --git a/source/test/fixtures/module-resolution/node16-from-package-json/index.test-d.ts b/source/test/fixtures/module-resolution/node16-from-package-json/index.test-d.ts new file mode 100644 index 00000000..439b1c52 --- /dev/null +++ b/source/test/fixtures/module-resolution/node16-from-package-json/index.test-d.ts @@ -0,0 +1,4 @@ +import foo from "foo"; +import {expectType} from '../../../..'; + +expectType(foo); diff --git a/source/test/fixtures/module-resolution/node16-from-package-json/package.json b/source/test/fixtures/module-resolution/node16-from-package-json/package.json new file mode 100644 index 00000000..cd91e482 --- /dev/null +++ b/source/test/fixtures/module-resolution/node16-from-package-json/package.json @@ -0,0 +1,9 @@ +{ + "name": "foo", + "exports": "./index.js", + "tsd": { + "compilerOptions": { + "module": "node16" + } + } +} diff --git a/source/test/fixtures/module-resolution/node16-from-tsconfig-json/index.d.ts b/source/test/fixtures/module-resolution/node16-from-tsconfig-json/index.d.ts new file mode 100644 index 00000000..eb851a2b --- /dev/null +++ b/source/test/fixtures/module-resolution/node16-from-tsconfig-json/index.d.ts @@ -0,0 +1,3 @@ +declare const foo: string; + +export default foo; diff --git a/source/test/fixtures/module-resolution/node16-from-tsconfig-json/index.js b/source/test/fixtures/module-resolution/node16-from-tsconfig-json/index.js new file mode 100644 index 00000000..2aac3ab1 --- /dev/null +++ b/source/test/fixtures/module-resolution/node16-from-tsconfig-json/index.js @@ -0,0 +1 @@ +module.exports.default = "foo"; diff --git a/source/test/fixtures/module-resolution/node16-from-tsconfig-json/index.test-d.ts b/source/test/fixtures/module-resolution/node16-from-tsconfig-json/index.test-d.ts new file mode 100644 index 00000000..439b1c52 --- /dev/null +++ b/source/test/fixtures/module-resolution/node16-from-tsconfig-json/index.test-d.ts @@ -0,0 +1,4 @@ +import foo from "foo"; +import {expectType} from '../../../..'; + +expectType(foo); diff --git a/source/test/fixtures/module-resolution/node16-from-tsconfig-json/package.json b/source/test/fixtures/module-resolution/node16-from-tsconfig-json/package.json new file mode 100644 index 00000000..d5527b68 --- /dev/null +++ b/source/test/fixtures/module-resolution/node16-from-tsconfig-json/package.json @@ -0,0 +1,4 @@ +{ + "name": "foo", + "exports": "./index.js" +} diff --git a/source/test/fixtures/module-resolution/node16-from-tsconfig-json/tsconfig.json b/source/test/fixtures/module-resolution/node16-from-tsconfig-json/tsconfig.json new file mode 100644 index 00000000..18c102cd --- /dev/null +++ b/source/test/fixtures/module-resolution/node16-from-tsconfig-json/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "module": "node16" + } +} diff --git a/source/test/fixtures/module-resolution/nodenext-from-package-json/index.d.ts b/source/test/fixtures/module-resolution/nodenext-from-package-json/index.d.ts new file mode 100644 index 00000000..eb851a2b --- /dev/null +++ b/source/test/fixtures/module-resolution/nodenext-from-package-json/index.d.ts @@ -0,0 +1,3 @@ +declare const foo: string; + +export default foo; diff --git a/source/test/fixtures/module-resolution/nodenext-from-package-json/index.js b/source/test/fixtures/module-resolution/nodenext-from-package-json/index.js new file mode 100644 index 00000000..2aac3ab1 --- /dev/null +++ b/source/test/fixtures/module-resolution/nodenext-from-package-json/index.js @@ -0,0 +1 @@ +module.exports.default = "foo"; diff --git a/source/test/fixtures/module-resolution/nodenext-from-package-json/index.test-d.ts b/source/test/fixtures/module-resolution/nodenext-from-package-json/index.test-d.ts new file mode 100644 index 00000000..439b1c52 --- /dev/null +++ b/source/test/fixtures/module-resolution/nodenext-from-package-json/index.test-d.ts @@ -0,0 +1,4 @@ +import foo from "foo"; +import {expectType} from '../../../..'; + +expectType(foo); diff --git a/source/test/fixtures/module-resolution/nodenext-from-package-json/package.json b/source/test/fixtures/module-resolution/nodenext-from-package-json/package.json new file mode 100644 index 00000000..069a05ce --- /dev/null +++ b/source/test/fixtures/module-resolution/nodenext-from-package-json/package.json @@ -0,0 +1,9 @@ +{ + "name": "foo", + "exports": "./index.js", + "tsd": { + "compilerOptions": { + "module": "nodenext" + } + } +} diff --git a/source/test/fixtures/module-resolution/nodenext-from-tsconfig-json/index.d.ts b/source/test/fixtures/module-resolution/nodenext-from-tsconfig-json/index.d.ts new file mode 100644 index 00000000..eb851a2b --- /dev/null +++ b/source/test/fixtures/module-resolution/nodenext-from-tsconfig-json/index.d.ts @@ -0,0 +1,3 @@ +declare const foo: string; + +export default foo; diff --git a/source/test/fixtures/module-resolution/nodenext-from-tsconfig-json/index.js b/source/test/fixtures/module-resolution/nodenext-from-tsconfig-json/index.js new file mode 100644 index 00000000..2aac3ab1 --- /dev/null +++ b/source/test/fixtures/module-resolution/nodenext-from-tsconfig-json/index.js @@ -0,0 +1 @@ +module.exports.default = "foo"; diff --git a/source/test/fixtures/module-resolution/nodenext-from-tsconfig-json/index.test-d.ts b/source/test/fixtures/module-resolution/nodenext-from-tsconfig-json/index.test-d.ts new file mode 100644 index 00000000..439b1c52 --- /dev/null +++ b/source/test/fixtures/module-resolution/nodenext-from-tsconfig-json/index.test-d.ts @@ -0,0 +1,4 @@ +import foo from "foo"; +import {expectType} from '../../../..'; + +expectType(foo); diff --git a/source/test/fixtures/module-resolution/nodenext-from-tsconfig-json/package.json b/source/test/fixtures/module-resolution/nodenext-from-tsconfig-json/package.json new file mode 100644 index 00000000..d5527b68 --- /dev/null +++ b/source/test/fixtures/module-resolution/nodenext-from-tsconfig-json/package.json @@ -0,0 +1,4 @@ +{ + "name": "foo", + "exports": "./index.js" +} diff --git a/source/test/fixtures/module-resolution/nodenext-from-tsconfig-json/tsconfig.json b/source/test/fixtures/module-resolution/nodenext-from-tsconfig-json/tsconfig.json new file mode 100644 index 00000000..7ce85cd7 --- /dev/null +++ b/source/test/fixtures/module-resolution/nodenext-from-tsconfig-json/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "module": "nodenext" + } +} diff --git a/source/test/test.ts b/source/test/test.ts index e84275f0..d8857073 100644 --- a/source/test/test.ts +++ b/source/test/test.ts @@ -138,6 +138,30 @@ test('allow specifying a lib in tsconfig.json', async t => { verify(t, diagnostics, []); }); +test('use moduleResolution NodeNext when module is nodenext in tsconfig.json', async t => { + const diagnostics = await tsd({cwd: path.join(__dirname, 'fixtures/module-resolution/nodenext-from-tsconfig-json')}); + + verify(t, diagnostics, []); +}); + +test('use moduleResolution NodeNext when module is nodenext in package.json', async t => { + const diagnostics = await tsd({cwd: path.join(__dirname, 'fixtures/module-resolution/nodenext-from-package-json')}); + + verify(t, diagnostics, []); +}); + +test('use moduleResolution Node16 when module is node16 in tsconfig.json', async t => { + const diagnostics = await tsd({cwd: path.join(__dirname, 'fixtures/module-resolution/node16-from-tsconfig-json')}); + + verify(t, diagnostics, []); +}); + +test('use moduleResolution Node16 when module is node16 in package.json', async t => { + const diagnostics = await tsd({cwd: path.join(__dirname, 'fixtures/module-resolution/node16-from-package-json')}); + + verify(t, diagnostics, []); +}); + test('add support for esm with esModuleInterop', async t => { const diagnostics = await tsd({ cwd: path.join(__dirname, 'fixtures/esm') From 89b4ff5a2529beb50b91228ceecee4ec4cb4806c Mon Sep 17 00:00:00 2001 From: Julian Grinblat Date: Mon, 13 Jun 2022 18:41:50 +0900 Subject: [PATCH 2/5] Cleanup --- source/lib/config.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/source/lib/config.ts b/source/lib/config.ts index bbd88435..dfbac109 100644 --- a/source/lib/config.ts +++ b/source/lib/config.ts @@ -32,6 +32,8 @@ export default (pkg: PackageJsonWithTsdConfig, cwd: string): Config => { ...packageJsonCompilerOptions, }; + const module = combinedCompilerOptions.module ?? ModuleKind.CommonJS; + return { directory: 'test-d', ...pkgConfig, @@ -39,17 +41,15 @@ export default (pkg: PackageJsonWithTsdConfig, cwd: string): Config => { strict: true, jsx: JsxEmit.React, lib: parseRawLibs(['es2017', 'dom', 'dom.iterable'], cwd), - module: ModuleKind.CommonJS, + module, target: ScriptTarget.ES2017, esModuleInterop: true, ...combinedCompilerOptions, - moduleResolution: combinedCompilerOptions.module === undefined ? - ModuleResolutionKind.NodeJs : - combinedCompilerOptions.module === ModuleKind.NodeNext ? - ModuleResolutionKind.NodeNext : - combinedCompilerOptions.module === ModuleKind.Node16 ? - ModuleResolutionKind.Node16 : - ModuleResolutionKind.NodeJs, + moduleResolution: combinedCompilerOptions.module === ModuleKind.NodeNext ? + ModuleResolutionKind.NodeNext : + combinedCompilerOptions.module === ModuleKind.Node16 ? + ModuleResolutionKind.Node16 : + ModuleResolutionKind.NodeJs, skipLibCheck: false } }; From d8ceecdb075ac1c306b9ff2db788387deae22f26 Mon Sep 17 00:00:00 2001 From: Julian Grinblat Date: Mon, 13 Jun 2022 18:44:20 +0900 Subject: [PATCH 3/5] Cleanup --- source/lib/config.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/lib/config.ts b/source/lib/config.ts index dfbac109..93d19d89 100644 --- a/source/lib/config.ts +++ b/source/lib/config.ts @@ -45,9 +45,9 @@ export default (pkg: PackageJsonWithTsdConfig, cwd: string): Config => { target: ScriptTarget.ES2017, esModuleInterop: true, ...combinedCompilerOptions, - moduleResolution: combinedCompilerOptions.module === ModuleKind.NodeNext ? + moduleResolution: module === ModuleKind.NodeNext ? ModuleResolutionKind.NodeNext : - combinedCompilerOptions.module === ModuleKind.Node16 ? + module === ModuleKind.Node16 ? ModuleResolutionKind.Node16 : ModuleResolutionKind.NodeJs, skipLibCheck: false From a6048394f933358e5c7b3ed55fb0fef217c220ee Mon Sep 17 00:00:00 2001 From: Julian Grinblat Date: Wed, 29 Jun 2022 12:57:28 +0900 Subject: [PATCH 4/5] Address comments --- readme.md | 5 +++-- .../module-resolution/node16-from-package-json/index.js | 2 +- .../node16-from-package-json/index.test-d.ts | 2 +- .../node16-from-package-json/package.json | 1 + .../module-resolution/node16-from-tsconfig-json/index.js | 2 +- .../node16-from-tsconfig-json/index.test-d.ts | 2 +- .../node16-from-tsconfig-json/package.json | 1 + .../module-resolution/nodenext-from-package-json/index.js | 2 +- .../nodenext-from-package-json/index.test-d.ts | 2 +- .../nodenext-from-package-json/package.json | 1 + .../nodenext-from-tsconfig-json/index.js | 2 +- .../nodenext-from-tsconfig-json/index.test-d.ts | 2 +- .../nodenext-from-tsconfig-json/package.json | 1 + source/test/test.ts | 8 ++++---- 14 files changed, 19 insertions(+), 14 deletions(-) diff --git a/readme.md b/readme.md index 86996002..a6a0f30d 100644 --- a/readme.md +++ b/readme.md @@ -135,7 +135,8 @@ By default, `tsd` applies the following configuration: "target": "es2017", "lib": ["es2017"], "module": "commonjs", - // The following option is set and is not overridable: + // The following option is set and is not overridable. + // It is set to `nodenext` if `module` is `nodenext`, `node16` if `module` is `node16` or `node` otherwise. "moduleResolution": "node" | "node16" | "nodenext" } ``` @@ -153,7 +154,7 @@ These options will be overridden if a `tsconfig.json` file is found in your proj } ``` -*Default options will apply if you don't override them explicitly.* You can't override the `moduleResolution` option. `moduleResolution` is set to `nodenext` if `module` is `nodenext`, `node16` if `module` is `node16` or `node` otherwise. +*Default options will apply if you don't override them explicitly.* You can't override the `moduleResolution` option. ## Assertions diff --git a/source/test/fixtures/module-resolution/node16-from-package-json/index.js b/source/test/fixtures/module-resolution/node16-from-package-json/index.js index 2aac3ab1..7f0fda40 100644 --- a/source/test/fixtures/module-resolution/node16-from-package-json/index.js +++ b/source/test/fixtures/module-resolution/node16-from-package-json/index.js @@ -1 +1 @@ -module.exports.default = "foo"; +module.exports.default = 'foo'; diff --git a/source/test/fixtures/module-resolution/node16-from-package-json/index.test-d.ts b/source/test/fixtures/module-resolution/node16-from-package-json/index.test-d.ts index 439b1c52..d43f96b1 100644 --- a/source/test/fixtures/module-resolution/node16-from-package-json/index.test-d.ts +++ b/source/test/fixtures/module-resolution/node16-from-package-json/index.test-d.ts @@ -1,4 +1,4 @@ -import foo from "foo"; +import foo from 'foo'; import {expectType} from '../../../..'; expectType(foo); diff --git a/source/test/fixtures/module-resolution/node16-from-package-json/package.json b/source/test/fixtures/module-resolution/node16-from-package-json/package.json index cd91e482..e6db8b83 100644 --- a/source/test/fixtures/module-resolution/node16-from-package-json/package.json +++ b/source/test/fixtures/module-resolution/node16-from-package-json/package.json @@ -1,5 +1,6 @@ { "name": "foo", + "type": "module", "exports": "./index.js", "tsd": { "compilerOptions": { diff --git a/source/test/fixtures/module-resolution/node16-from-tsconfig-json/index.js b/source/test/fixtures/module-resolution/node16-from-tsconfig-json/index.js index 2aac3ab1..7f0fda40 100644 --- a/source/test/fixtures/module-resolution/node16-from-tsconfig-json/index.js +++ b/source/test/fixtures/module-resolution/node16-from-tsconfig-json/index.js @@ -1 +1 @@ -module.exports.default = "foo"; +module.exports.default = 'foo'; diff --git a/source/test/fixtures/module-resolution/node16-from-tsconfig-json/index.test-d.ts b/source/test/fixtures/module-resolution/node16-from-tsconfig-json/index.test-d.ts index 439b1c52..d43f96b1 100644 --- a/source/test/fixtures/module-resolution/node16-from-tsconfig-json/index.test-d.ts +++ b/source/test/fixtures/module-resolution/node16-from-tsconfig-json/index.test-d.ts @@ -1,4 +1,4 @@ -import foo from "foo"; +import foo from 'foo'; import {expectType} from '../../../..'; expectType(foo); diff --git a/source/test/fixtures/module-resolution/node16-from-tsconfig-json/package.json b/source/test/fixtures/module-resolution/node16-from-tsconfig-json/package.json index d5527b68..75bc3f28 100644 --- a/source/test/fixtures/module-resolution/node16-from-tsconfig-json/package.json +++ b/source/test/fixtures/module-resolution/node16-from-tsconfig-json/package.json @@ -1,4 +1,5 @@ { "name": "foo", + "type": "module", "exports": "./index.js" } diff --git a/source/test/fixtures/module-resolution/nodenext-from-package-json/index.js b/source/test/fixtures/module-resolution/nodenext-from-package-json/index.js index 2aac3ab1..7f0fda40 100644 --- a/source/test/fixtures/module-resolution/nodenext-from-package-json/index.js +++ b/source/test/fixtures/module-resolution/nodenext-from-package-json/index.js @@ -1 +1 @@ -module.exports.default = "foo"; +module.exports.default = 'foo'; diff --git a/source/test/fixtures/module-resolution/nodenext-from-package-json/index.test-d.ts b/source/test/fixtures/module-resolution/nodenext-from-package-json/index.test-d.ts index 439b1c52..d43f96b1 100644 --- a/source/test/fixtures/module-resolution/nodenext-from-package-json/index.test-d.ts +++ b/source/test/fixtures/module-resolution/nodenext-from-package-json/index.test-d.ts @@ -1,4 +1,4 @@ -import foo from "foo"; +import foo from 'foo'; import {expectType} from '../../../..'; expectType(foo); diff --git a/source/test/fixtures/module-resolution/nodenext-from-package-json/package.json b/source/test/fixtures/module-resolution/nodenext-from-package-json/package.json index 069a05ce..dde0bd2a 100644 --- a/source/test/fixtures/module-resolution/nodenext-from-package-json/package.json +++ b/source/test/fixtures/module-resolution/nodenext-from-package-json/package.json @@ -1,5 +1,6 @@ { "name": "foo", + "type": "module", "exports": "./index.js", "tsd": { "compilerOptions": { diff --git a/source/test/fixtures/module-resolution/nodenext-from-tsconfig-json/index.js b/source/test/fixtures/module-resolution/nodenext-from-tsconfig-json/index.js index 2aac3ab1..7f0fda40 100644 --- a/source/test/fixtures/module-resolution/nodenext-from-tsconfig-json/index.js +++ b/source/test/fixtures/module-resolution/nodenext-from-tsconfig-json/index.js @@ -1 +1 @@ -module.exports.default = "foo"; +module.exports.default = 'foo'; diff --git a/source/test/fixtures/module-resolution/nodenext-from-tsconfig-json/index.test-d.ts b/source/test/fixtures/module-resolution/nodenext-from-tsconfig-json/index.test-d.ts index 439b1c52..d43f96b1 100644 --- a/source/test/fixtures/module-resolution/nodenext-from-tsconfig-json/index.test-d.ts +++ b/source/test/fixtures/module-resolution/nodenext-from-tsconfig-json/index.test-d.ts @@ -1,4 +1,4 @@ -import foo from "foo"; +import foo from 'foo'; import {expectType} from '../../../..'; expectType(foo); diff --git a/source/test/fixtures/module-resolution/nodenext-from-tsconfig-json/package.json b/source/test/fixtures/module-resolution/nodenext-from-tsconfig-json/package.json index d5527b68..75bc3f28 100644 --- a/source/test/fixtures/module-resolution/nodenext-from-tsconfig-json/package.json +++ b/source/test/fixtures/module-resolution/nodenext-from-tsconfig-json/package.json @@ -1,4 +1,5 @@ { "name": "foo", + "type": "module", "exports": "./index.js" } diff --git a/source/test/test.ts b/source/test/test.ts index d8857073..4c09266e 100644 --- a/source/test/test.ts +++ b/source/test/test.ts @@ -138,25 +138,25 @@ test('allow specifying a lib in tsconfig.json', async t => { verify(t, diagnostics, []); }); -test('use moduleResolution NodeNext when module is nodenext in tsconfig.json', async t => { +test('use moduleResolution `nodenext` when module is `nodenext` in tsconfig.json', async t => { const diagnostics = await tsd({cwd: path.join(__dirname, 'fixtures/module-resolution/nodenext-from-tsconfig-json')}); verify(t, diagnostics, []); }); -test('use moduleResolution NodeNext when module is nodenext in package.json', async t => { +test('use moduleResolution `nodenext` when module is `nodenext` in package.json', async t => { const diagnostics = await tsd({cwd: path.join(__dirname, 'fixtures/module-resolution/nodenext-from-package-json')}); verify(t, diagnostics, []); }); -test('use moduleResolution Node16 when module is node16 in tsconfig.json', async t => { +test('use moduleResolution `node16` when module is `node16` in tsconfig.json', async t => { const diagnostics = await tsd({cwd: path.join(__dirname, 'fixtures/module-resolution/node16-from-tsconfig-json')}); verify(t, diagnostics, []); }); -test('use moduleResolution Node16 when module is node16 in package.json', async t => { +test('use moduleResolution `node16` when module is `node16` in package.json', async t => { const diagnostics = await tsd({cwd: path.join(__dirname, 'fixtures/module-resolution/node16-from-package-json')}); verify(t, diagnostics, []); From a1f2e0c0aef5fc3134197538e4c9de7927fa4dfe Mon Sep 17 00:00:00 2001 From: Julian Grinblat Date: Wed, 29 Jun 2022 13:26:44 +0900 Subject: [PATCH 5/5] Fix --- .../module-resolution/node16-from-package-json/index.test-d.ts | 2 +- .../module-resolution/node16-from-tsconfig-json/index.test-d.ts | 2 +- .../nodenext-from-package-json/index.test-d.ts | 2 +- .../nodenext-from-tsconfig-json/index.test-d.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/source/test/fixtures/module-resolution/node16-from-package-json/index.test-d.ts b/source/test/fixtures/module-resolution/node16-from-package-json/index.test-d.ts index d43f96b1..09a2d6c1 100644 --- a/source/test/fixtures/module-resolution/node16-from-package-json/index.test-d.ts +++ b/source/test/fixtures/module-resolution/node16-from-package-json/index.test-d.ts @@ -1,4 +1,4 @@ import foo from 'foo'; -import {expectType} from '../../../..'; +import {expectType} from '../../../../index.js'; expectType(foo); diff --git a/source/test/fixtures/module-resolution/node16-from-tsconfig-json/index.test-d.ts b/source/test/fixtures/module-resolution/node16-from-tsconfig-json/index.test-d.ts index d43f96b1..09a2d6c1 100644 --- a/source/test/fixtures/module-resolution/node16-from-tsconfig-json/index.test-d.ts +++ b/source/test/fixtures/module-resolution/node16-from-tsconfig-json/index.test-d.ts @@ -1,4 +1,4 @@ import foo from 'foo'; -import {expectType} from '../../../..'; +import {expectType} from '../../../../index.js'; expectType(foo); diff --git a/source/test/fixtures/module-resolution/nodenext-from-package-json/index.test-d.ts b/source/test/fixtures/module-resolution/nodenext-from-package-json/index.test-d.ts index d43f96b1..09a2d6c1 100644 --- a/source/test/fixtures/module-resolution/nodenext-from-package-json/index.test-d.ts +++ b/source/test/fixtures/module-resolution/nodenext-from-package-json/index.test-d.ts @@ -1,4 +1,4 @@ import foo from 'foo'; -import {expectType} from '../../../..'; +import {expectType} from '../../../../index.js'; expectType(foo); diff --git a/source/test/fixtures/module-resolution/nodenext-from-tsconfig-json/index.test-d.ts b/source/test/fixtures/module-resolution/nodenext-from-tsconfig-json/index.test-d.ts index d43f96b1..09a2d6c1 100644 --- a/source/test/fixtures/module-resolution/nodenext-from-tsconfig-json/index.test-d.ts +++ b/source/test/fixtures/module-resolution/nodenext-from-tsconfig-json/index.test-d.ts @@ -1,4 +1,4 @@ import foo from 'foo'; -import {expectType} from '../../../..'; +import {expectType} from '../../../../index.js'; expectType(foo);