From bc7b87172ad25d1096fb506207583fbf7b7d1d22 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Fri, 21 Feb 2025 11:14:55 -0800 Subject: [PATCH 1/6] Add tests --- .../reference/erasableSyntaxOnly.errors.txt | 10 +++ .../baselines/reference/erasableSyntaxOnly.js | 18 +++++ .../reference/erasableSyntaxOnly.symbols | 10 +++ .../reference/erasableSyntaxOnly.types | 72 +++++++++++++++++++ tests/cases/compiler/erasableSyntaxOnly.ts | 10 +++ 5 files changed, 120 insertions(+) diff --git a/tests/baselines/reference/erasableSyntaxOnly.errors.txt b/tests/baselines/reference/erasableSyntaxOnly.errors.txt index 2005ef65de8e7..21eac48f47865 100644 --- a/tests/baselines/reference/erasableSyntaxOnly.errors.txt +++ b/tests/baselines/reference/erasableSyntaxOnly.errors.txt @@ -92,6 +92,16 @@ index.ts(28,12): error TS1294: This syntax is not allowed when 'erasableSyntaxOn import FineAlias = EnumInAmbientContext.B; } + // Not erasable + (()=>{})(); + (()=>< any >{})(); + (()=> < any > {})(); + + // Erasable + (()=>({}))(); + (()=>({}))(); + {}; + ==== commonjs.cts (2 errors) ==== import foo = require("./other.cjs"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/erasableSyntaxOnly.js b/tests/baselines/reference/erasableSyntaxOnly.js index 9edf749d7b038..17287bb3d7195 100644 --- a/tests/baselines/reference/erasableSyntaxOnly.js +++ b/tests/baselines/reference/erasableSyntaxOnly.js @@ -65,6 +65,16 @@ declare namespace AmbientStuff { import FineAlias = EnumInAmbientContext.B; } + +// Not erasable +(()=>{})(); +(()=>< any >{})(); +(()=> < any > {})(); + +// Erasable +(()=>({}))(); +(()=>({}))(); +{}; //// [commonjs.cts] import foo = require("./other.cjs"); @@ -120,6 +130,14 @@ var MyClassOk = /** @class */ (function () { } return MyClassOk; }()); +// Not erasable +(function () { return ({}); })(); +(function () { return ({}); })(); +(function () { return ({}); })(); +// Erasable +(function () { return ({}); })(); +(function () { return ({}); })(); +({}); //// [commonjs.cjs] "use strict"; var foo = require("./other.cjs"); diff --git a/tests/baselines/reference/erasableSyntaxOnly.symbols b/tests/baselines/reference/erasableSyntaxOnly.symbols index 8e057dc990217..713abaa5d2cc9 100644 --- a/tests/baselines/reference/erasableSyntaxOnly.symbols +++ b/tests/baselines/reference/erasableSyntaxOnly.symbols @@ -118,6 +118,16 @@ declare namespace AmbientStuff { >B : Symbol(FineAlias, Decl(index.ts, 58, 31)) } +// Not erasable +(()=>{})(); +(()=>< any >{})(); +(()=> < any > {})(); + +// Erasable +(()=>({}))(); +(()=>({}))(); +{}; + === commonjs.cts === import foo = require("./other.cjs"); >foo : Symbol(foo, Decl(commonjs.cts, 0, 0)) diff --git a/tests/baselines/reference/erasableSyntaxOnly.types b/tests/baselines/reference/erasableSyntaxOnly.types index 4d4ddaea49701..a3c326de7fa38 100644 --- a/tests/baselines/reference/erasableSyntaxOnly.types +++ b/tests/baselines/reference/erasableSyntaxOnly.types @@ -160,6 +160,78 @@ declare namespace AmbientStuff { > : ^^^^^^^^^^^^^^^^^^^^^^ } +// Not erasable +(()=>{})(); +>(()=>{})() : any +> : ^^^ +>(()=>{}) : () => any +> : ^^^^^^ +>()=>{} : () => any +> : ^^^^^^ +>{} : any +> : ^^^ +>{} : {} +> : ^^ + +(()=>< any >{})(); +>(()=>< any >{})() : any +> : ^^^ +>(()=>< any >{}) : () => any +> : ^^^^^^ +>()=>< any >{} : () => any +> : ^^^^^^ +>< any >{} : any +> : ^^^ +>{} : {} +> : ^^ + +(()=> < any > {})(); +>(()=> < any > {})() : any +> : ^^^ +>(()=> < any > {}) : () => any +> : ^^^^^^ +>()=> < any > {} : () => any +> : ^^^^^^ +>< any > {} : any +> : ^^^ +>{} : {} +> : ^^ + +// Erasable +(()=>({}))(); +>(()=>({}))() : any +> : ^^^ +>(()=>({})) : () => any +> : ^^^^^^ +>()=>({}) : () => any +> : ^^^^^^ +>({}) : any +> : ^^^ +>({}) : {} +> : ^^ +>{} : {} +> : ^^ + +(()=>({}))(); +>(()=>({}))() : any +> : ^^^ +>(()=>({})) : () => any +> : ^^^^^^^^^ +>()=>({}) : () => any +> : ^^^^^^^^^ +>({}) : any +> : ^^^ +>{} : any +> : ^^^ +>{} : {} +> : ^^ + +{}; +>{} : any +> : ^^^ +>{} : {} +> : ^^ + === commonjs.cts === import foo = require("./other.cjs"); >foo : () => void diff --git a/tests/cases/compiler/erasableSyntaxOnly.ts b/tests/cases/compiler/erasableSyntaxOnly.ts index d2ff6d72ce8f3..81fd5c4c6af5f 100644 --- a/tests/cases/compiler/erasableSyntaxOnly.ts +++ b/tests/cases/compiler/erasableSyntaxOnly.ts @@ -66,6 +66,16 @@ declare namespace AmbientStuff { import FineAlias = EnumInAmbientContext.B; } +// Not erasable +(()=>{})(); +(()=>< any >{})(); +(()=> < any > {})(); + +// Erasable +(()=>({}))(); +(()=>({}))(); +{}; + // @filename: commonjs.cts import foo = require("./other.cjs"); export = foo; From 6bb413d4bfeb5b22af8775e944a27fe7d9b451df Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Fri, 21 Feb 2025 11:56:27 -0800 Subject: [PATCH 2/6] Ban old-style type assertions as arrow function bodies under erasableSyntaxOnly --- src/compiler/checker.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7c5958106334a..ec55f4fd44313 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -37312,6 +37312,15 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (file && fileExtensionIsOneOf(file.fileName, [Extension.Cts, Extension.Mts])) { grammarErrorOnNode(node, Diagnostics.This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead); } + if ( + compilerOptions.erasableSyntaxOnly + && node.expression.kind === SyntaxKind.ObjectLiteralExpression + && node.parent.kind === SyntaxKind.ArrowFunction && (node.parent as ArrowFunction).body == node + ) { + const start = node.type.pos - "<".length; + const end = skipTrivia(file.text, node.type.end) + ">".length; + diagnostics.add(createFileDiagnostic(file, start, end - start, Diagnostics.This_syntax_is_not_allowed_when_erasableSyntaxOnly_is_enabled)); + } } return checkAssertionWorker(node, checkMode); } From 11f330ac377eb3661a22826bf235662441d93e95 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Fri, 21 Feb 2025 11:58:39 -0800 Subject: [PATCH 3/6] eqeqeq --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ec55f4fd44313..c550e074b2d7e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -37315,7 +37315,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if ( compilerOptions.erasableSyntaxOnly && node.expression.kind === SyntaxKind.ObjectLiteralExpression - && node.parent.kind === SyntaxKind.ArrowFunction && (node.parent as ArrowFunction).body == node + && node.parent.kind === SyntaxKind.ArrowFunction && (node.parent as ArrowFunction).body === node ) { const start = node.type.pos - "<".length; const end = skipTrivia(file.text, node.type.end) + ">".length; From 14d24618f0fc2735a310d28188d0a2a8735d0024 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Fri, 21 Feb 2025 16:07:50 -0800 Subject: [PATCH 4/6] actually commit the baselines --- .../baselines/reference/erasableSyntaxOnly.errors.txt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/baselines/reference/erasableSyntaxOnly.errors.txt b/tests/baselines/reference/erasableSyntaxOnly.errors.txt index 21eac48f47865..277ee2dd207ed 100644 --- a/tests/baselines/reference/erasableSyntaxOnly.errors.txt +++ b/tests/baselines/reference/erasableSyntaxOnly.errors.txt @@ -8,9 +8,12 @@ index.ts(17,15): error TS1294: This syntax is not allowed when 'erasableSyntaxOn index.ts(22,6): error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. index.ts(26,1): error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. index.ts(28,12): error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. +index.ts(67,6): error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. +index.ts(68,6): error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. +index.ts(69,7): error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. -==== index.ts (8 errors) ==== +==== index.ts (11 errors) ==== class MyClassErr { // No parameter properties constructor(public foo: string) { } @@ -94,8 +97,14 @@ index.ts(28,12): error TS1294: This syntax is not allowed when 'erasableSyntaxOn // Not erasable (()=>{})(); + ~~~~~ +!!! error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. (()=>< any >{})(); + ~~~~~~~ +!!! error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. (()=> < any > {})(); + ~~~~~~~ +!!! error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. // Erasable (()=>({}))(); From 5ef765b0ff761d30f092981e2775549dbf8c0c7a Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 26 Feb 2025 12:11:24 -0800 Subject: [PATCH 5/6] more test --- .../reference/erasableSyntaxOnly.errors.txt | 22 ++++++ .../baselines/reference/erasableSyntaxOnly.js | 70 +++++++++++++++++++ .../reference/erasableSyntaxOnly.symbols | 25 +++++++ .../reference/erasableSyntaxOnly.types | 63 +++++++++++++++++ tests/cases/compiler/erasableSyntaxOnly.ts | 20 ++++++ 5 files changed, 200 insertions(+) diff --git a/tests/baselines/reference/erasableSyntaxOnly.errors.txt b/tests/baselines/reference/erasableSyntaxOnly.errors.txt index 277ee2dd207ed..e2ceb46b3a1bc 100644 --- a/tests/baselines/reference/erasableSyntaxOnly.errors.txt +++ b/tests/baselines/reference/erasableSyntaxOnly.errors.txt @@ -1,3 +1,4 @@ +error TS2318: Cannot find global type 'IterableIterator'. commonjs.cts(1,1): error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. commonjs.cts(2,1): error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. index.ts(3,17): error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. @@ -13,6 +14,7 @@ index.ts(68,6): error TS1294: This syntax is not allowed when 'erasableSyntaxOnl index.ts(69,7): error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. +!!! error TS2318: Cannot find global type 'IterableIterator'. ==== index.ts (11 errors) ==== class MyClassErr { // No parameter properties @@ -111,6 +113,26 @@ index.ts(69,7): error TS1294: This syntax is not allowed when 'erasableSyntaxOnl (()=>({}))(); {}; + + // return and yield ASI + function *gen() { + yield + 1; + return + 1; + } + + // at the start of an ExpressionStatement if followed by an object literal; though I'm not sure why one would use it there + {foo() {}}.foo(); + + // at the start of an ExpressionStatement if followed by function keyword + function() {}(); + function() {}; + + // at the start of an ExpressionStatement if followed by an anonymous class expression + // note that this exact syntax currently emits invalid JS (no parenthesis added like for function above) + class {} + ==== commonjs.cts (2 errors) ==== import foo = require("./other.cjs"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/erasableSyntaxOnly.js b/tests/baselines/reference/erasableSyntaxOnly.js index 17287bb3d7195..beb8262097152 100644 --- a/tests/baselines/reference/erasableSyntaxOnly.js +++ b/tests/baselines/reference/erasableSyntaxOnly.js @@ -75,6 +75,26 @@ declare namespace AmbientStuff { (()=>({}))(); (()=>({}))(); {}; + + +// return and yield ASI +function *gen() { + yield + 1; + return + 1; +} + +// at the start of an ExpressionStatement if followed by an object literal; though I'm not sure why one would use it there +{foo() {}}.foo(); + +// at the start of an ExpressionStatement if followed by function keyword +function() {}(); +function() {}; + +// at the start of an ExpressionStatement if followed by an anonymous class expression +// note that this exact syntax currently emits invalid JS (no parenthesis added like for function above) +class {} //// [commonjs.cts] import foo = require("./other.cjs"); @@ -92,6 +112,33 @@ export default foo; //// [index.js] +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype); + return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; var MyClassErr = /** @class */ (function () { // No parameter properties function MyClassErr(foo) { @@ -138,6 +185,29 @@ var MyClassOk = /** @class */ (function () { (function () { return ({}); })(); (function () { return ({}); })(); ({}); +// return and yield ASI +function gen() { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, 1]; + case 1: + _a.sent(); + return [2 /*return*/, 1]; + } + }); +} +// at the start of an ExpressionStatement if followed by an object literal; though I'm not sure why one would use it there +({ foo: function () { } }.foo()); +// at the start of an ExpressionStatement if followed by function keyword +(function () { })(); +(function () { }); +// at the start of an ExpressionStatement if followed by an anonymous class expression +// note that this exact syntax currently emits invalid JS (no parenthesis added like for function above) +/** @class */ (function () { + function class_1() { + } + return class_1; +}()); //// [commonjs.cjs] "use strict"; var foo = require("./other.cjs"); diff --git a/tests/baselines/reference/erasableSyntaxOnly.symbols b/tests/baselines/reference/erasableSyntaxOnly.symbols index 713abaa5d2cc9..659c5df9d59fc 100644 --- a/tests/baselines/reference/erasableSyntaxOnly.symbols +++ b/tests/baselines/reference/erasableSyntaxOnly.symbols @@ -128,6 +128,31 @@ declare namespace AmbientStuff { (()=>({}))(); {}; + +// return and yield ASI +function *gen() { +>gen : Symbol(gen, Decl(index.ts, 73, 8)) + + yield + 1; + return + 1; +} + +// at the start of an ExpressionStatement if followed by an object literal; though I'm not sure why one would use it there +{foo() {}}.foo(); +>{foo() {}}.foo : Symbol(foo, Decl(index.ts, 85, 10)) +>foo : Symbol(foo, Decl(index.ts, 85, 10)) +>foo : Symbol(foo, Decl(index.ts, 85, 10)) + +// at the start of an ExpressionStatement if followed by function keyword +function() {}(); +function() {}; + +// at the start of an ExpressionStatement if followed by an anonymous class expression +// note that this exact syntax currently emits invalid JS (no parenthesis added like for function above) +class {} + === commonjs.cts === import foo = require("./other.cjs"); >foo : Symbol(foo, Decl(commonjs.cts, 0, 0)) diff --git a/tests/baselines/reference/erasableSyntaxOnly.types b/tests/baselines/reference/erasableSyntaxOnly.types index a3c326de7fa38..b252f35f322e3 100644 --- a/tests/baselines/reference/erasableSyntaxOnly.types +++ b/tests/baselines/reference/erasableSyntaxOnly.types @@ -232,6 +232,69 @@ declare namespace AmbientStuff { >{} : {} > : ^^ + +// return and yield ASI +function *gen() { +>gen : () => {} +> : ^^^^^^^^ + + yield +>yield 1 : any +> : ^^^ +> 1 : any +> : ^^^ + + 1; +>1 : 1 +> : ^ + + return +> 1 : any +> : ^^^ + + 1; +>1 : 1 +> : ^ +} + +// at the start of an ExpressionStatement if followed by an object literal; though I'm not sure why one would use it there +{foo() {}}.foo(); +>{foo() {}}.foo() : unknown +> : ^^^^^^^ +>{foo() {}}.foo() : void +> : ^^^^ +>{foo() {}}.foo : () => void +> : ^^^^^^^^^^ +>{foo() {}} : { foo(): void; } +> : ^^^^^^^^^^^^^^^^ +>foo : () => void +> : ^^^^^^^^^^ +>foo : () => void +> : ^^^^^^^^^^ + +// at the start of an ExpressionStatement if followed by function keyword +function() {}(); +>function() {}() : unknown +> : ^^^^^^^ +>function() {}() : void +> : ^^^^ +>function() {} : () => void +> : ^^^^^^^^^^ + +function() {}; +>function() {} : unknown +> : ^^^^^^^ +>function() {} : () => void +> : ^^^^^^^^^^ + +// at the start of an ExpressionStatement if followed by an anonymous class expression +// note that this exact syntax currently emits invalid JS (no parenthesis added like for function above) +class {} +>class {} : unknown +> : ^^^^^^^ +>class {} : typeof (Anonymous class) +> : ^^^^^^^^^^^^^^^^^^^^^^^^ + === commonjs.cts === import foo = require("./other.cjs"); >foo : () => void diff --git a/tests/cases/compiler/erasableSyntaxOnly.ts b/tests/cases/compiler/erasableSyntaxOnly.ts index 81fd5c4c6af5f..1df8b3116442c 100644 --- a/tests/cases/compiler/erasableSyntaxOnly.ts +++ b/tests/cases/compiler/erasableSyntaxOnly.ts @@ -76,6 +76,26 @@ declare namespace AmbientStuff { (()=>({}))(); {}; + +// return and yield ASI +function *gen() { + yield + 1; + return + 1; +} + +// at the start of an ExpressionStatement if followed by an object literal; though I'm not sure why one would use it there +{foo() {}}.foo(); + +// at the start of an ExpressionStatement if followed by function keyword +function() {}(); +function() {}; + +// at the start of an ExpressionStatement if followed by an anonymous class expression +// note that this exact syntax currently emits invalid JS (no parenthesis added like for function above) +class {} + // @filename: commonjs.cts import foo = require("./other.cjs"); export = foo; From 01d72c19aed5b58b55f9d72473a133a3bdd23a78 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 26 Feb 2025 12:11:55 -0800 Subject: [PATCH 6/6] Ban them all --- src/compiler/checker.ts | 6 +--- .../reference/erasableSyntaxOnly.errors.txt | 29 ++++++++++++++++++- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c550e074b2d7e..fbf8d4e342dcc 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -37312,11 +37312,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (file && fileExtensionIsOneOf(file.fileName, [Extension.Cts, Extension.Mts])) { grammarErrorOnNode(node, Diagnostics.This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead); } - if ( - compilerOptions.erasableSyntaxOnly - && node.expression.kind === SyntaxKind.ObjectLiteralExpression - && node.parent.kind === SyntaxKind.ArrowFunction && (node.parent as ArrowFunction).body === node - ) { + if (compilerOptions.erasableSyntaxOnly) { const start = node.type.pos - "<".length; const end = skipTrivia(file.text, node.type.end) + ">".length; diagnostics.add(createFileDiagnostic(file, start, end - start, Diagnostics.This_syntax_is_not_allowed_when_erasableSyntaxOnly_is_enabled)); diff --git a/tests/baselines/reference/erasableSyntaxOnly.errors.txt b/tests/baselines/reference/erasableSyntaxOnly.errors.txt index e2ceb46b3a1bc..523da93fd9d39 100644 --- a/tests/baselines/reference/erasableSyntaxOnly.errors.txt +++ b/tests/baselines/reference/erasableSyntaxOnly.errors.txt @@ -12,10 +12,19 @@ index.ts(28,12): error TS1294: This syntax is not allowed when 'erasableSyntaxOn index.ts(67,6): error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. index.ts(68,6): error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. index.ts(69,7): error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. +index.ts(72,6): error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. +index.ts(73,7): error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. +index.ts(74,1): error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. +index.ts(79,11): error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. +index.ts(81,12): error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. +index.ts(86,1): error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. +index.ts(89,1): error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. +index.ts(90,1): error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. +index.ts(94,1): error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. !!! error TS2318: Cannot find global type 'IterableIterator'. -==== index.ts (11 errors) ==== +==== index.ts (20 errors) ==== class MyClassErr { // No parameter properties constructor(public foo: string) { } @@ -110,28 +119,46 @@ index.ts(69,7): error TS1294: This syntax is not allowed when 'erasableSyntaxOnl // Erasable (()=>({}))(); + ~~~~~ +!!! error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. (()=>({}))(); + ~~~~~ +!!! error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. {}; + ~~~~~ +!!! error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. // return and yield ASI function *gen() { yield + ~~~~~ +!!! error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. 1; return + ~~~~~ +!!! error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. 1; } // at the start of an ExpressionStatement if followed by an object literal; though I'm not sure why one would use it there {foo() {}}.foo(); + ~~~~~~~~~ +!!! error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. // at the start of an ExpressionStatement if followed by function keyword function() {}(); + ~~~~~~~~~ +!!! error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. function() {}; + ~~~~~~~~~ +!!! error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. // at the start of an ExpressionStatement if followed by an anonymous class expression // note that this exact syntax currently emits invalid JS (no parenthesis added like for function above) class {} + ~~~~~~~~~ +!!! error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. ==== commonjs.cts (2 errors) ==== import foo = require("./other.cjs");