-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support resolution-mode overrides in type-only constructs in all modu…
…leResolution modes (#55725)
- Loading branch information
1 parent
2e9e9a2
commit 1b70ac3
Showing
41 changed files
with
1,708 additions
and
121 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
45 changes: 0 additions & 45 deletions
45
...elines/reference/nodeModulesTripleSlashReferenceModeOverrideOldResolutionError.errors.txt
This file was deleted.
Oops, something went wrong.
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
23 changes: 21 additions & 2 deletions
23
...baselines/reference/nodeModulesTripleSlashReferenceModeOverrideOldResolutionError.symbols
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 |
---|---|---|
@@ -1,9 +1,28 @@ | ||
//// [tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeOverrideOldResolutionError.ts] //// | ||
|
||
=== /index.ts === | ||
|
||
/// <reference types="pkg" resolution-mode="require" /> | ||
/// <reference types="pkg" resolution-mode="import" /> | ||
foo; // `resolution-mode` is an error in old resolution settings, which resolves is arbitrary | ||
foo; | ||
>foo : Symbol(foo, Decl(import.d.ts, 2, 7)) | ||
|
||
bar; | ||
>bar : Symbol(bar, Decl(require.d.ts, 2, 7)) | ||
|
||
export {}; | ||
=== /node_modules/pkg/import.d.ts === | ||
export {}; | ||
declare global { | ||
>global : Symbol(global, Decl(import.d.ts, 0, 10)) | ||
|
||
var foo: number; | ||
>foo : Symbol(foo, Decl(import.d.ts, 2, 7)) | ||
} | ||
=== /node_modules/pkg/require.d.ts === | ||
export {}; | ||
declare global { | ||
>global : Symbol(global, Decl(require.d.ts, 0, 10)) | ||
|
||
var bar: number; | ||
>bar : Symbol(bar, Decl(require.d.ts, 2, 7)) | ||
} |
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
36 changes: 36 additions & 0 deletions
36
tests/baselines/reference/resolutionModeImportType1(moduleresolution=bundler).symbols
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,36 @@ | ||
//// [tests/cases/conformance/moduleResolution/resolutionModeImportType1.ts] //// | ||
|
||
=== /node_modules/@types/foo/index.d.mts === | ||
export declare const x: "module"; | ||
>x : Symbol(x, Decl(index.d.mts, 0, 20)) | ||
|
||
=== /node_modules/@types/foo/index.d.cts === | ||
export declare const x: "script"; | ||
>x : Symbol(x, Decl(index.d.cts, 0, 20)) | ||
|
||
=== /app.ts === | ||
type Default = typeof import("foo").x; | ||
>Default : Symbol(Default, Decl(app.ts, 0, 0)) | ||
>x : Symbol(x, Decl(index.d.mts, 0, 20)) | ||
|
||
type Import = typeof import("foo", { assert: { "resolution-mode": "import" } }).x; | ||
>Import : Symbol(Import, Decl(app.ts, 0, 38)) | ||
>x : Symbol(x, Decl(index.d.mts, 0, 20)) | ||
|
||
type Require = typeof import("foo", { assert: { "resolution-mode": "require" } }).x; | ||
>Require : Symbol(Require, Decl(app.ts, 1, 82)) | ||
>x : Symbol(x, Decl(index.d.cts, 0, 20)) | ||
|
||
// resolution-mode does not enforce file extension in `bundler`, just sets conditions | ||
type ImportRelative = typeof import("./other", { assert: { "resolution-mode": "import" } }).x; | ||
>ImportRelative : Symbol(ImportRelative, Decl(app.ts, 2, 84)) | ||
>x : Symbol(x, Decl(other.ts, 0, 12)) | ||
|
||
type RequireRelative = typeof import("./other", { assert: { "resolution-mode": "require" } }).x; | ||
>RequireRelative : Symbol(RequireRelative, Decl(app.ts, 4, 94)) | ||
>x : Symbol(x, Decl(other.ts, 0, 12)) | ||
|
||
=== /other.ts === | ||
export const x = "other"; | ||
>x : Symbol(x, Decl(other.ts, 0, 12)) | ||
|
37 changes: 37 additions & 0 deletions
37
tests/baselines/reference/resolutionModeImportType1(moduleresolution=bundler).types
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,37 @@ | ||
//// [tests/cases/conformance/moduleResolution/resolutionModeImportType1.ts] //// | ||
|
||
=== /node_modules/@types/foo/index.d.mts === | ||
export declare const x: "module"; | ||
>x : "module" | ||
|
||
=== /node_modules/@types/foo/index.d.cts === | ||
export declare const x: "script"; | ||
>x : "script" | ||
|
||
=== /app.ts === | ||
type Default = typeof import("foo").x; | ||
>Default : "module" | ||
>x : error | ||
|
||
type Import = typeof import("foo", { assert: { "resolution-mode": "import" } }).x; | ||
>Import : "module" | ||
>x : error | ||
|
||
type Require = typeof import("foo", { assert: { "resolution-mode": "require" } }).x; | ||
>Require : "script" | ||
>x : error | ||
|
||
// resolution-mode does not enforce file extension in `bundler`, just sets conditions | ||
type ImportRelative = typeof import("./other", { assert: { "resolution-mode": "import" } }).x; | ||
>ImportRelative : "other" | ||
>x : error | ||
|
||
type RequireRelative = typeof import("./other", { assert: { "resolution-mode": "require" } }).x; | ||
>RequireRelative : "other" | ||
>x : error | ||
|
||
=== /other.ts === | ||
export const x = "other"; | ||
>x : "other" | ||
>"other" : "other" | ||
|
46 changes: 46 additions & 0 deletions
46
tests/baselines/reference/resolutionModeImportType1(moduleresolution=classic).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,46 @@ | ||
error TS2688: Cannot find type definition file for 'foo'. | ||
The file is in the program because: | ||
Entry point for implicit type library 'foo' | ||
/app.ts(1,30): error TS2792: Cannot find module 'foo'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? | ||
/app.ts(2,29): error TS2792: Cannot find module 'foo'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? | ||
/app.ts(3,30): error TS2792: Cannot find module 'foo'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? | ||
|
||
|
||
!!! error TS2688: Cannot find type definition file for 'foo'. | ||
!!! error TS2688: The file is in the program because: | ||
!!! error TS2688: Entry point for implicit type library 'foo' | ||
==== /node_modules/@types/foo/package.json (0 errors) ==== | ||
{ | ||
"name": "@types/foo", | ||
"version": "1.0.0", | ||
"exports": { | ||
".": { | ||
"import": "./index.d.mts", | ||
"require": "./index.d.cts" | ||
} | ||
} | ||
} | ||
|
||
==== /node_modules/@types/foo/index.d.mts (0 errors) ==== | ||
export declare const x: "module"; | ||
|
||
==== /node_modules/@types/foo/index.d.cts (0 errors) ==== | ||
export declare const x: "script"; | ||
|
||
==== /app.ts (3 errors) ==== | ||
type Default = typeof import("foo").x; | ||
~~~~~ | ||
!!! error TS2792: Cannot find module 'foo'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? | ||
type Import = typeof import("foo", { assert: { "resolution-mode": "import" } }).x; | ||
~~~~~ | ||
!!! error TS2792: Cannot find module 'foo'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? | ||
type Require = typeof import("foo", { assert: { "resolution-mode": "require" } }).x; | ||
~~~~~ | ||
!!! error TS2792: Cannot find module 'foo'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? | ||
// resolution-mode does not enforce file extension in `bundler`, just sets conditions | ||
type ImportRelative = typeof import("./other", { assert: { "resolution-mode": "import" } }).x; | ||
type RequireRelative = typeof import("./other", { assert: { "resolution-mode": "require" } }).x; | ||
|
||
==== /other.ts (0 errors) ==== | ||
export const x = "other"; | ||
|
33 changes: 33 additions & 0 deletions
33
tests/baselines/reference/resolutionModeImportType1(moduleresolution=classic).symbols
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,33 @@ | ||
//// [tests/cases/conformance/moduleResolution/resolutionModeImportType1.ts] //// | ||
|
||
=== /node_modules/@types/foo/index.d.mts === | ||
export declare const x: "module"; | ||
>x : Symbol(x, Decl(index.d.mts, 0, 20)) | ||
|
||
=== /node_modules/@types/foo/index.d.cts === | ||
export declare const x: "script"; | ||
>x : Symbol(x, Decl(index.d.cts, 0, 20)) | ||
|
||
=== /app.ts === | ||
type Default = typeof import("foo").x; | ||
>Default : Symbol(Default, Decl(app.ts, 0, 0)) | ||
|
||
type Import = typeof import("foo", { assert: { "resolution-mode": "import" } }).x; | ||
>Import : Symbol(Import, Decl(app.ts, 0, 38)) | ||
|
||
type Require = typeof import("foo", { assert: { "resolution-mode": "require" } }).x; | ||
>Require : Symbol(Require, Decl(app.ts, 1, 82)) | ||
|
||
// resolution-mode does not enforce file extension in `bundler`, just sets conditions | ||
type ImportRelative = typeof import("./other", { assert: { "resolution-mode": "import" } }).x; | ||
>ImportRelative : Symbol(ImportRelative, Decl(app.ts, 2, 84)) | ||
>x : Symbol(x, Decl(other.ts, 0, 12)) | ||
|
||
type RequireRelative = typeof import("./other", { assert: { "resolution-mode": "require" } }).x; | ||
>RequireRelative : Symbol(RequireRelative, Decl(app.ts, 4, 94)) | ||
>x : Symbol(x, Decl(other.ts, 0, 12)) | ||
|
||
=== /other.ts === | ||
export const x = "other"; | ||
>x : Symbol(x, Decl(other.ts, 0, 12)) | ||
|
Oops, something went wrong.