-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix accidental ESM-mode directory module lookup in package non-root (#…
- Loading branch information
1 parent
0652664
commit 019fec8
Showing
3 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
tests/baselines/reference/nodeModulesNoDirectoryModule.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/index.ts(2,8): error TS2307: Cannot find module 'i-have-a-dir-and-main/dist/dir' or its corresponding type declarations. | ||
|
||
|
||
==== /node_modules/i-have-a-dir-and-main/package.json (0 errors) ==== | ||
{ | ||
"name": "i-have-a-dir-and-main", | ||
"version": "1.0.0", | ||
"type": "module", | ||
"main": "dist/index.js" | ||
} | ||
|
||
==== /node_modules/i-have-a-dir-and-main/dist/index.d.ts (0 errors) ==== | ||
export declare const a = 1; | ||
|
||
==== /node_modules/i-have-a-dir-and-main/dist/dir/index.d.ts (0 errors) ==== | ||
export declare const b = 2; | ||
|
||
==== /package.json (0 errors) ==== | ||
{ "type": "module" } | ||
|
||
==== /index.ts (1 errors) ==== | ||
import 'i-have-a-dir-and-main' // ok | ||
import 'i-have-a-dir-and-main/dist/dir' // error | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
!!! error TS2307: Cannot find module 'i-have-a-dir-and-main/dist/dir' or its corresponding type declarations. | ||
|
26 changes: 26 additions & 0 deletions
26
tests/cases/conformance/node/nodeModulesNoDirectoryModule.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// @noUncheckedSideEffectImports: true | ||
// @strict: true | ||
// @module: node16 | ||
// @noEmit: true | ||
// @noTypesAndSymbols: true | ||
|
||
// @Filename: /node_modules/i-have-a-dir-and-main/package.json | ||
{ | ||
"name": "i-have-a-dir-and-main", | ||
"version": "1.0.0", | ||
"type": "module", | ||
"main": "dist/index.js" | ||
} | ||
|
||
// @Filename: /node_modules/i-have-a-dir-and-main/dist/index.d.ts | ||
export declare const a = 1; | ||
|
||
// @Filename: /node_modules/i-have-a-dir-and-main/dist/dir/index.d.ts | ||
export declare const b = 2; | ||
|
||
// @Filename: /package.json | ||
{ "type": "module" } | ||
|
||
// @Filename: /index.ts | ||
import 'i-have-a-dir-and-main' // ok | ||
import 'i-have-a-dir-and-main/dist/dir' // error |