Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
) * package.json `exports` should have priority over `typesVersions` * Test some versioned conditions too
- Loading branch information
1 parent
acb8977
commit 221cf55a21e448bd3fe2cf26a754c9c0dda3dca3
Showing
12 changed files
with
1,022 additions
and
18 deletions.
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
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,92 @@ | ||
error TS6504: File '/node_modules/exports-and-types-versions/dist/foo.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? | ||
The file is in the program because: | ||
Root file specified for compilation | ||
/main.cts(1,16): error TS7016: Could not find a declaration file for module 'exports-and-types-versions/foo'. '/node_modules/exports-and-types-versions/dist/foo.js' implicitly has an 'any' type. | ||
If the 'exports-and-types-versions' package actually exposes this module, try adding a new declaration (.d.ts) file containing `declare module 'exports-and-types-versions/foo';` | ||
/main.cts(2,16): error TS2307: Cannot find module 'exports-and-types-versions/nope' or its corresponding type declarations. | ||
/main.cts(5,16): error TS2307: Cannot find module 'exports-and-types-versions/versioned-nah' or its corresponding type declarations. | ||
/main.mts(1,16): error TS7016: Could not find a declaration file for module 'exports-and-types-versions/foo'. '/node_modules/exports-and-types-versions/dist/foo.js' implicitly has an 'any' type. | ||
If the 'exports-and-types-versions' package actually exposes this module, try adding a new declaration (.d.ts) file containing `declare module 'exports-and-types-versions/foo';` | ||
/main.mts(2,16): error TS2307: Cannot find module 'exports-and-types-versions/nope' or its corresponding type declarations. | ||
/main.mts(5,16): error TS2307: Cannot find module 'exports-and-types-versions/versioned-nah' or its corresponding type declarations. | ||
|
||
|
||
!!! error TS6504: File '/node_modules/exports-and-types-versions/dist/foo.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? | ||
!!! error TS6504: The file is in the program because: | ||
!!! error TS6504: Root file specified for compilation | ||
==== /node_modules/exports-and-types-versions/package.json (0 errors) ==== | ||
{ | ||
"name": "exports-and-types-versions", | ||
"version": "1.0.0", | ||
"exports": { | ||
"./foo": "./dist/foo.js", | ||
"./yep": { | ||
"types": "./types/foo.d.ts", | ||
"default": "./dist/foo.js" | ||
}, | ||
"./versioned-yep": { | ||
"types@>=4": "./types/foo.d.ts" | ||
}, | ||
"./versioned-nah": { | ||
"types@<4": "./types/foo.d.ts" | ||
} | ||
}, | ||
"typesVersions": { | ||
"*": { | ||
"foo": ["./types/foo.d.ts"], | ||
"nope": ["./types/foo.d.ts"], | ||
"versioned-nah": ["./types/foo.d.ts"] | ||
} | ||
} | ||
} | ||
|
||
==== /node_modules/exports-and-types-versions/dist/foo.js (0 errors) ==== | ||
module.exports = {}; | ||
|
||
==== /node_modules/exports-and-types-versions/types/foo.d.ts (0 errors) ==== | ||
export {}; | ||
|
||
==== /node_modules/just-types-versions/package.json (0 errors) ==== | ||
{ | ||
"name": "just-types-versions", | ||
"version": "1.0.0", | ||
"typesVersions": { | ||
"*": { | ||
"foo": ["./types/foo.d.ts"] | ||
} | ||
} | ||
} | ||
|
||
==== /node_modules/just-types-versions/types/foo.d.ts (0 errors) ==== | ||
export {}; | ||
|
||
==== /main.cts (3 errors) ==== | ||
import {} from "exports-and-types-versions/foo"; | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
!!! error TS7016: Could not find a declaration file for module 'exports-and-types-versions/foo'. '/node_modules/exports-and-types-versions/dist/foo.js' implicitly has an 'any' type. | ||
!!! error TS7016: If the 'exports-and-types-versions' package actually exposes this module, try adding a new declaration (.d.ts) file containing `declare module 'exports-and-types-versions/foo';` | ||
import {} from "exports-and-types-versions/nope"; | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
!!! error TS2307: Cannot find module 'exports-and-types-versions/nope' or its corresponding type declarations. | ||
import {} from "exports-and-types-versions/yep"; | ||
import {} from "exports-and-types-versions/versioned-yep"; | ||
import {} from "exports-and-types-versions/versioned-nah"; | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
!!! error TS2307: Cannot find module 'exports-and-types-versions/versioned-nah' or its corresponding type declarations. | ||
import {} from "just-types-versions/foo"; | ||
|
||
==== /main.mts (3 errors) ==== | ||
import {} from "exports-and-types-versions/foo"; | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
!!! error TS7016: Could not find a declaration file for module 'exports-and-types-versions/foo'. '/node_modules/exports-and-types-versions/dist/foo.js' implicitly has an 'any' type. | ||
!!! error TS7016: If the 'exports-and-types-versions' package actually exposes this module, try adding a new declaration (.d.ts) file containing `declare module 'exports-and-types-versions/foo';` | ||
import {} from "exports-and-types-versions/nope"; | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
!!! error TS2307: Cannot find module 'exports-and-types-versions/nope' or its corresponding type declarations. | ||
import {} from "exports-and-types-versions/yep"; | ||
import {} from "exports-and-types-versions/versioned-yep"; | ||
import {} from "exports-and-types-versions/versioned-nah"; | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
!!! error TS2307: Cannot find module 'exports-and-types-versions/versioned-nah' or its corresponding type declarations. | ||
import {} from "just-types-versions/foo"; | ||
|
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,70 @@ | ||
//// [tests/cases/conformance/node/nodeModulesExportsBlocksTypesVersions.ts] //// | ||
|
||
//// [package.json] | ||
{ | ||
"name": "exports-and-types-versions", | ||
"version": "1.0.0", | ||
"exports": { | ||
"./foo": "./dist/foo.js", | ||
"./yep": { | ||
"types": "./types/foo.d.ts", | ||
"default": "./dist/foo.js" | ||
}, | ||
"./versioned-yep": { | ||
"types@>=4": "./types/foo.d.ts" | ||
}, | ||
"./versioned-nah": { | ||
"types@<4": "./types/foo.d.ts" | ||
} | ||
}, | ||
"typesVersions": { | ||
"*": { | ||
"foo": ["./types/foo.d.ts"], | ||
"nope": ["./types/foo.d.ts"], | ||
"versioned-nah": ["./types/foo.d.ts"] | ||
} | ||
} | ||
} | ||
|
||
//// [foo.js] | ||
module.exports = {}; | ||
|
||
//// [foo.d.ts] | ||
export {}; | ||
|
||
//// [package.json] | ||
{ | ||
"name": "just-types-versions", | ||
"version": "1.0.0", | ||
"typesVersions": { | ||
"*": { | ||
"foo": ["./types/foo.d.ts"] | ||
} | ||
} | ||
} | ||
|
||
//// [foo.d.ts] | ||
export {}; | ||
|
||
//// [main.cts] | ||
import {} from "exports-and-types-versions/foo"; | ||
import {} from "exports-and-types-versions/nope"; | ||
import {} from "exports-and-types-versions/yep"; | ||
import {} from "exports-and-types-versions/versioned-yep"; | ||
import {} from "exports-and-types-versions/versioned-nah"; | ||
import {} from "just-types-versions/foo"; | ||
|
||
//// [main.mts] | ||
import {} from "exports-and-types-versions/foo"; | ||
import {} from "exports-and-types-versions/nope"; | ||
import {} from "exports-and-types-versions/yep"; | ||
import {} from "exports-and-types-versions/versioned-yep"; | ||
import {} from "exports-and-types-versions/versioned-nah"; | ||
import {} from "just-types-versions/foo"; | ||
|
||
|
||
//// [main.cjs] | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//// [main.mjs] | ||
export {}; |
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,23 @@ | ||
=== /node_modules/exports-and-types-versions/types/foo.d.ts === | ||
export {}; | ||
No type information for this code. | ||
No type information for this code.=== /node_modules/just-types-versions/types/foo.d.ts === | ||
export {}; | ||
No type information for this code. | ||
No type information for this code.=== /main.cts === | ||
import {} from "exports-and-types-versions/foo"; | ||
No type information for this code.import {} from "exports-and-types-versions/nope"; | ||
No type information for this code.import {} from "exports-and-types-versions/yep"; | ||
No type information for this code.import {} from "exports-and-types-versions/versioned-yep"; | ||
No type information for this code.import {} from "exports-and-types-versions/versioned-nah"; | ||
No type information for this code.import {} from "just-types-versions/foo"; | ||
No type information for this code. | ||
No type information for this code.=== /main.mts === | ||
import {} from "exports-and-types-versions/foo"; | ||
No type information for this code.import {} from "exports-and-types-versions/nope"; | ||
No type information for this code.import {} from "exports-and-types-versions/yep"; | ||
No type information for this code.import {} from "exports-and-types-versions/versioned-yep"; | ||
No type information for this code.import {} from "exports-and-types-versions/versioned-nah"; | ||
No type information for this code.import {} from "just-types-versions/foo"; | ||
No type information for this code. | ||
No type information for this code. |
Oops, something went wrong.