Skip to content

Commit 003cf69

Browse files
TypeScript BotDanielRosenwassertypescript-bot
authored and
dar
committed
🤖 Pick PR microsoft#53240 (Allow 'verbatimModuleSyntax' with t...) into release-5.0 (microsoft#53253)
Co-authored-by: Daniel Rosenwasser <[email protected]> Co-authored-by: typescript-bot <[email protected]>
1 parent c5c40cb commit 003cf69

File tree

283 files changed

+1463
-75
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

283 files changed

+1463
-75
lines changed

‎lib/tsserver.js

+8
Original file line numberDiff line numberDiff line change
@@ -133402,6 +133402,11 @@ function canBeConvertedToAsync(node) {
133402133402
}
133403133403

133404133404
// src/services/transpile.ts
133405+
var optionsRedundantWithVerbatimModuleSyntax = /* @__PURE__ */ new Set([
133406+
"isolatedModules",
133407+
"preserveValueImports",
133408+
"importsNotUsedAsValues"
133409+
]);
133405133410
function transpileModule(input, transpileOptions) {
133406133411
const diagnostics = [];
133407133412
const options = transpileOptions.compilerOptions ? fixupCompilerOptions(transpileOptions.compilerOptions, diagnostics) : {};
@@ -133412,6 +133417,9 @@ function transpileModule(input, transpileOptions) {
133412133417
}
133413133418
}
133414133419
for (const option of transpileOptionValueCompilerOptions) {
133420+
if (options.verbatimModuleSyntax && optionsRedundantWithVerbatimModuleSyntax.has(option.name)) {
133421+
continue;
133422+
}
133415133423
options[option.name] = option.transpileOptionValue;
133416133424
}
133417133425
options.suppressOutputPathCheck = true;

‎lib/tsserverlibrary.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -131819,6 +131819,9 @@ ${lanes.join("\n")}
131819131819
}
131820131820
}
131821131821
for (const option of transpileOptionValueCompilerOptions) {
131822+
if (options.verbatimModuleSyntax && optionsRedundantWithVerbatimModuleSyntax.has(option.name)) {
131823+
continue;
131824+
}
131822131825
options[option.name] = option.transpileOptionValue;
131823131826
}
131824131827
options.suppressOutputPathCheck = true;
@@ -131922,11 +131925,16 @@ ${lanes.join("\n")}
131922131925
}
131923131926
return options;
131924131927
}
131925-
var commandLineOptionsStringToEnum;
131928+
var optionsRedundantWithVerbatimModuleSyntax, commandLineOptionsStringToEnum;
131926131929
var init_transpile = __esm({
131927131930
"src/services/transpile.ts"() {
131928131931
"use strict";
131929131932
init_ts4();
131933+
optionsRedundantWithVerbatimModuleSyntax = /* @__PURE__ */ new Set([
131934+
"isolatedModules",
131935+
"preserveValueImports",
131936+
"importsNotUsedAsValues"
131937+
]);
131930131938
}
131931131939
});
131932131940

‎lib/typescript.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -131833,6 +131833,9 @@ ${lanes.join("\n")}
131833131833
}
131834131834
}
131835131835
for (const option of transpileOptionValueCompilerOptions) {
131836+
if (options.verbatimModuleSyntax && optionsRedundantWithVerbatimModuleSyntax.has(option.name)) {
131837+
continue;
131838+
}
131836131839
options[option.name] = option.transpileOptionValue;
131837131840
}
131838131841
options.suppressOutputPathCheck = true;
@@ -131936,11 +131939,16 @@ ${lanes.join("\n")}
131936131939
}
131937131940
return options;
131938131941
}
131939-
var commandLineOptionsStringToEnum;
131942+
var optionsRedundantWithVerbatimModuleSyntax, commandLineOptionsStringToEnum;
131940131943
var init_transpile = __esm({
131941131944
"src/services/transpile.ts"() {
131942131945
"use strict";
131943131946
init_ts4();
131947+
optionsRedundantWithVerbatimModuleSyntax = /* @__PURE__ */ new Set([
131948+
"isolatedModules",
131949+
"preserveValueImports",
131950+
"importsNotUsedAsValues"
131951+
]);
131944131952
}
131945131953
});
131946131954

‎src/services/transpile.ts

+11
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ export interface TranspileOutput {
4343
sourceMapText?: string;
4444
}
4545

46+
const optionsRedundantWithVerbatimModuleSyntax = new Set([
47+
"isolatedModules",
48+
"preserveValueImports",
49+
"importsNotUsedAsValues"
50+
]);
51+
4652
/*
4753
* This function will compile source text from 'input' argument using specified compiler options.
4854
* If not options are provided - it will use a set of default compiler options.
@@ -66,6 +72,11 @@ export function transpileModule(input: string, transpileOptions: TranspileOption
6672
}
6773

6874
for (const option of transpileOptionValueCompilerOptions) {
75+
// Do not set redundant config options if `verbatimModuleSyntax` was supplied.
76+
if (options.verbatimModuleSyntax && optionsRedundantWithVerbatimModuleSyntax.has(option.name)) {
77+
continue;
78+
}
79+
6980
options[option.name] = option.transpileOptionValue;
7081
}
7182

‎src/testRunner/unittests/services/transpile.ts

+178-73
Large diffs are not rendered by default.

‎tests/baselines/reference/transpile/Correctly serialize metadata when transpile with CommonJS option (verbatimModuleSyntax=true).js

+24
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎tests/baselines/reference/transpile/Correctly serialize metadata when transpile with CommonJS option (verbatimModuleSyntax=true).oldTranspile.js

+24
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error.
2+
3+
4+
!!! error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error.
5+
==== file.ts (0 errors) ====
6+
import IFoo = Namespace.IFoo;export type { IFoo };

‎tests/baselines/reference/transpile/Does not elide import equals referenced only by export type (verbatimModuleSyntax=true).js

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error.
2+
3+
4+
!!! error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error.
5+
==== file.ts (0 errors) ====
6+
import IFoo = Namespace.IFoo;export type { IFoo };

‎tests/baselines/reference/transpile/Does not elide import equals referenced only by export type (verbatimModuleSyntax=true).oldTranspile.js

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error.
2+
3+
4+
!!! error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error.
5+
==== file.ts (0 errors) ====
6+
import IFoo = Namespace.IFoo;export { type IFoo };

‎tests/baselines/reference/transpile/Does not elide import equals referenced only by type only export specifier (verbatimModuleSyntax=true).js

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error.
2+
3+
4+
!!! error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error.
5+
==== file.ts (0 errors) ====
6+
import IFoo = Namespace.IFoo;export { type IFoo };

‎tests/baselines/reference/transpile/Does not elide import equals referenced only by type only export specifier (verbatimModuleSyntax=true).oldTranspile.js

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error.
2+
3+
4+
!!! error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error.
5+
==== file.ts (0 errors) ====
6+
var x: string = 0;

‎tests/baselines/reference/transpile/Does not generate semantic diagnostics (verbatimModuleSyntax=true).js

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error.
2+
3+
4+
!!! error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error.
5+
==== file.ts (0 errors) ====
6+
var x: string = 0;

‎tests/baselines/reference/transpile/Does not generate semantic diagnostics (verbatimModuleSyntax=true).oldTranspile.js

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error TS5104: Option 'isolatedModules' is redundant and cannot be specified with option 'verbatimModuleSyntax'.
2+
error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error.
3+
4+
5+
!!! error TS5104: Option 'isolatedModules' is redundant and cannot be specified with option 'verbatimModuleSyntax'.
6+
!!! error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error.
7+
==== input.js (0 errors) ====
8+
x;

‎tests/baselines/reference/transpile/Does not support setting isolatedModules (verbatimModuleSyntax=true).js

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error TS5104: Option 'isolatedModules' is redundant and cannot be specified with option 'verbatimModuleSyntax'.
2+
error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error.
3+
4+
5+
!!! error TS5104: Option 'isolatedModules' is redundant and cannot be specified with option 'verbatimModuleSyntax'.
6+
!!! error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error.
7+
==== input.js (0 errors) ====
8+
x;

‎tests/baselines/reference/transpile/Does not support setting isolatedModules (verbatimModuleSyntax=true).oldTranspile.js

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error.
2+
3+
4+
!!! error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error.
5+
==== file.ts (0 errors) ====
6+
7+
var a;
8+
export { a as alias };
9+
export * as alias from './file';

‎tests/baselines/reference/transpile/Export star as ns conflict does not crash (verbatimModuleSyntax=true).js

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error.
2+
3+
4+
!!! error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error.
5+
==== file.ts (0 errors) ====
6+
7+
var a;
8+
export { a as alias };
9+
export * as alias from './file';

‎tests/baselines/reference/transpile/Export star as ns conflict does not crash (verbatimModuleSyntax=true).oldTranspile.js

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error.
2+
file.ts(1,1): error TS1434: Unexpected keyword or identifier.
3+
4+
5+
!!! error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error.
6+
==== file.ts (1 errors) ====
7+
a b
8+
~
9+
!!! error TS1434: Unexpected keyword or identifier.

‎tests/baselines/reference/transpile/Generates expected syntactic diagnostics (verbatimModuleSyntax=true).js

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error.
2+
file.ts(1,1): error TS1434: Unexpected keyword or identifier.
3+
4+
5+
!!! error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error.
6+
==== file.ts (1 errors) ====
7+
a b
8+
~
9+
!!! error TS1434: Unexpected keyword or identifier.

‎tests/baselines/reference/transpile/Generates expected syntactic diagnostics (verbatimModuleSyntax=true).oldTranspile.js

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error.
2+
3+
4+
!!! error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error.
5+
==== file.ts (0 errors) ====
6+
/// <reference path="file2.ts" />
7+
var x = 0;

‎tests/baselines/reference/transpile/Generates no diagnostics for missing file references (verbatimModuleSyntax=true).js

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error.
2+
3+
4+
!!! error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error.
5+
==== file.ts (0 errors) ====
6+
/// <reference path="file2.ts" />
7+
var x = 0;

‎tests/baselines/reference/transpile/Generates no diagnostics for missing file references (verbatimModuleSyntax=true).oldTranspile.js

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error.
2+
3+
4+
!!! error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error.
5+
==== file.ts (0 errors) ====
6+
import {a} from "module2";

‎tests/baselines/reference/transpile/Generates no diagnostics for missing module imports (verbatimModuleSyntax=true).js

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error.
2+
3+
4+
!!! error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error.
5+
==== file.ts (0 errors) ====
6+
import {a} from "module2";

‎tests/baselines/reference/transpile/Generates no diagnostics for missing module imports (verbatimModuleSyntax=true).oldTranspile.js

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error.
2+
3+
4+
!!! error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error.
5+
==== file.ts (0 errors) ====
6+
var x = 0;

0 commit comments

Comments
 (0)