Skip to content

Commit ed9c522

Browse files
authored
Accept new moduleResolution options on commandline (microsoft#46239)
1 parent cb158e7 commit ed9c522

34 files changed

Lines changed: 587 additions & 1 deletion

File tree

src/compiler/commandLineParser.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,8 @@ namespace ts {
748748
type: new Map(getEntries({
749749
node: ModuleResolutionKind.NodeJs,
750750
classic: ModuleResolutionKind.Classic,
751+
node12: ModuleResolutionKind.Node12,
752+
nodenext: ModuleResolutionKind.NodeNext,
751753
})),
752754
affectsModuleResolution: true,
753755
paramType: Diagnostics.STRATEGY,

src/testRunner/compilerRunner.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ namespace Harness {
117117
class CompilerTest {
118118
private static varyBy: readonly string[] = [
119119
"module",
120+
"moduleResolution",
120121
"target",
121122
"jsx",
122123
"removeComments",

src/testRunner/unittests/config/commandLineParsing.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ namespace ts {
237237
start: undefined,
238238
length: undefined,
239239
}, {
240-
messageText: "Argument for '--moduleResolution' option must be: 'node', 'classic'.",
240+
messageText: "Argument for '--moduleResolution' option must be: 'node', 'classic', 'node12', 'nodenext'.",
241241
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
242242
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
243243

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
tests/cases/compiler/index.ts(1,20): error TS2307: Cannot find module 'pkg' or its corresponding type declarations.
2+
3+
4+
==== tests/cases/compiler/node_modules/pkg/package.json (0 errors) ====
5+
{
6+
"name": "pkg",
7+
"version": "0.0.1",
8+
"exports": "./entrypoint.js"
9+
}
10+
==== tests/cases/compiler/node_modules/pkg/entrypoint.d.ts (0 errors) ====
11+
export declare function thing(): void;
12+
==== tests/cases/compiler/index.ts (1 errors) ====
13+
import * as p from "pkg";
14+
~~~~~
15+
!!! error TS2307: Cannot find module 'pkg' or its corresponding type declarations.
16+
p.thing();
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//// [tests/cases/compiler/moduleResolutionWithModule.ts] ////
2+
3+
//// [package.json]
4+
{
5+
"name": "pkg",
6+
"version": "0.0.1",
7+
"exports": "./entrypoint.js"
8+
}
9+
//// [entrypoint.d.ts]
10+
export declare function thing(): void;
11+
//// [index.ts]
12+
import * as p from "pkg";
13+
p.thing();
14+
15+
//// [index.js]
16+
"use strict";
17+
exports.__esModule = true;
18+
var p = require("pkg");
19+
p.thing();
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
=== tests/cases/compiler/node_modules/pkg/entrypoint.d.ts ===
2+
export declare function thing(): void;
3+
>thing : Symbol(thing, Decl(entrypoint.d.ts, 0, 0))
4+
5+
=== tests/cases/compiler/index.ts ===
6+
import * as p from "pkg";
7+
>p : Symbol(p, Decl(index.ts, 0, 6))
8+
9+
p.thing();
10+
>p : Symbol(p, Decl(index.ts, 0, 6))
11+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
=== tests/cases/compiler/node_modules/pkg/entrypoint.d.ts ===
2+
export declare function thing(): void;
3+
>thing : () => void
4+
5+
=== tests/cases/compiler/index.ts ===
6+
import * as p from "pkg";
7+
>p : any
8+
9+
p.thing();
10+
>p.thing() : any
11+
>p.thing : any
12+
>p : any
13+
>thing : any
14+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//// [tests/cases/compiler/moduleResolutionWithModule.ts] ////
2+
3+
//// [package.json]
4+
{
5+
"name": "pkg",
6+
"version": "0.0.1",
7+
"exports": "./entrypoint.js"
8+
}
9+
//// [entrypoint.d.ts]
10+
export declare function thing(): void;
11+
//// [index.ts]
12+
import * as p from "pkg";
13+
p.thing();
14+
15+
//// [index.js]
16+
"use strict";
17+
exports.__esModule = true;
18+
var p = require("pkg");
19+
p.thing();
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
=== tests/cases/compiler/node_modules/pkg/entrypoint.d.ts ===
2+
export declare function thing(): void;
3+
>thing : Symbol(thing, Decl(entrypoint.d.ts, 0, 0))
4+
5+
=== tests/cases/compiler/index.ts ===
6+
import * as p from "pkg";
7+
>p : Symbol(p, Decl(index.ts, 0, 6))
8+
9+
p.thing();
10+
>p.thing : Symbol(p.thing, Decl(entrypoint.d.ts, 0, 0))
11+
>p : Symbol(p, Decl(index.ts, 0, 6))
12+
>thing : Symbol(p.thing, Decl(entrypoint.d.ts, 0, 0))
13+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
=== tests/cases/compiler/node_modules/pkg/entrypoint.d.ts ===
2+
export declare function thing(): void;
3+
>thing : () => void
4+
5+
=== tests/cases/compiler/index.ts ===
6+
import * as p from "pkg";
7+
>p : typeof p
8+
9+
p.thing();
10+
>p.thing() : void
11+
>p.thing : () => void
12+
>p : typeof p
13+
>thing : () => void
14+

0 commit comments

Comments
 (0)