Skip to content

Commit ae1b3db

Browse files
Allow 'verbatimModuleSyntax' with transpileModule (#53240)
Co-authored-by: Daniel Rosenwasser <[email protected]>
1 parent 2378c0b commit ae1b3db

File tree

280 files changed

+1437
-73
lines changed

Some content is hidden

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

280 files changed

+1437
-73
lines changed

src/services/transpile.ts

Lines changed: 11 additions & 0 deletions
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

Lines changed: 178 additions & 73 deletions
Large diffs are not rendered by default.

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

Lines changed: 24 additions & 0 deletions
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

Lines changed: 24 additions & 0 deletions
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

Lines changed: 4 additions & 0 deletions
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

Lines changed: 4 additions & 0 deletions
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

Lines changed: 4 additions & 0 deletions
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

Lines changed: 4 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 7 additions & 0 deletions
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

Lines changed: 7 additions & 0 deletions
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

Lines changed: 3 additions & 0 deletions
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

Lines changed: 3 additions & 0 deletions
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

Lines changed: 3 additions & 0 deletions
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

Lines changed: 3 additions & 0 deletions
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

Lines changed: 4 additions & 0 deletions
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

Lines changed: 4 additions & 0 deletions
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;

tests/baselines/reference/transpile/Generates no diagnostics with valid inputs (verbatimModuleSyntax=true).js

Lines changed: 2 additions & 0 deletions
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;

tests/baselines/reference/transpile/Generates no diagnostics with valid inputs (verbatimModuleSyntax=true).oldTranspile.js

Lines changed: 2 additions & 0 deletions
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+
const fn = <T>(a: T) => a

tests/baselines/reference/transpile/Infer correct file extension (verbatimModuleSyntax=true).js

Lines changed: 2 additions & 0 deletions
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+
const fn = <T>(a: T) => a

tests/baselines/reference/transpile/Infer correct file extension (verbatimModuleSyntax=true).oldTranspile.js

Lines changed: 2 additions & 0 deletions
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 (0 errors) ====
6+
"use strict";
7+
var x = 0;

tests/baselines/reference/transpile/No extra errors for file without extension (verbatimModuleSyntax=true).js

Lines changed: 3 additions & 0 deletions
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 (0 errors) ====
6+
"use strict";
7+
var x = 0;

tests/baselines/reference/transpile/No extra errors for file without extension (verbatimModuleSyntax=true).oldTranspile.js

Lines changed: 3 additions & 0 deletions
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+
==== input.js (0 errors) ====
6+
const a = 10;

0 commit comments

Comments
 (0)