diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index d95001b104106..73ef633955209 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -1208,7 +1208,7 @@ namespace ts { bind(node.statement); popActiveLabel(); if (!activeLabel.referenced && !options.allowUnusedLabels) { - file.bindDiagnostics.push(createDiagnosticForNode(node.label, Diagnostics.Unused_label)); + errorOrSuggestionOnFirstToken(unusedLabelIsError(options), node, Diagnostics.Unused_label); } if (!node.statement || node.statement.kind !== SyntaxKind.DoStatement) { // do statement sets current flow inside bindDoStatement @@ -1914,6 +1914,17 @@ namespace ts { file.bindDiagnostics.push(createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2)); } + function errorOrSuggestionOnFirstToken(isError: boolean, node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any) { + const span = getSpanOfTokenAtPosition(file, node.pos); + const diag = createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2); + if (isError) { + file.bindDiagnostics.push(diag); + } + else { + file.bindSuggestionDiagnostics = append(file.bindSuggestionDiagnostics, { ...diag, category: DiagnosticCategory.Suggestion }); + } + } + function bind(node: Node): void { if (!node) { return; @@ -2730,26 +2741,26 @@ namespace ts { if (reportError) { currentFlow = reportedUnreachableFlow; - // unreachable code is reported if - // - user has explicitly asked about it AND - // - statement is in not ambient context (statements in ambient context is already an error - // so we should not report extras) AND - // - node is not variable statement OR - // - node is block scoped variable statement OR - // - node is not block scoped variable statement and at least one variable declaration has initializer - // Rationale: we don't want to report errors on non-initialized var's since they are hoisted - // On the other side we do want to report errors on non-initialized 'lets' because of TDZ - const reportUnreachableCode = - !options.allowUnreachableCode && - !(node.flags & NodeFlags.Ambient) && - ( - node.kind !== SyntaxKind.VariableStatement || - getCombinedNodeFlags((node).declarationList) & NodeFlags.BlockScoped || - forEach((node).declarationList.declarations, d => d.initializer) - ); - - if (reportUnreachableCode) { - errorOnFirstToken(node, Diagnostics.Unreachable_code_detected); + if (!options.allowUnreachableCode) { + // unreachable code is reported if + // - user has explicitly asked about it AND + // - statement is in not ambient context (statements in ambient context is already an error + // so we should not report extras) AND + // - node is not variable statement OR + // - node is block scoped variable statement OR + // - node is not block scoped variable statement and at least one variable declaration has initializer + // Rationale: we don't want to report errors on non-initialized var's since they are hoisted + // On the other side we do want to report errors on non-initialized 'lets' because of TDZ + const isError = + unreachableCodeIsError(options) && + !(node.flags & NodeFlags.Ambient) && + ( + !isVariableStatement(node) || + !!(getCombinedNodeFlags(node.declarationList) & NodeFlags.BlockScoped) || + node.declarationList.declarations.some(d => !!d.initializer) + ); + + errorOrSuggestionOnFirstToken(isError, node, Diagnostics.Unreachable_code_detected); } } } diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 41e754a689e79..3dff6a673658b 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1991,6 +1991,14 @@ namespace ts { return moduleResolution; } + export function unreachableCodeIsError(options: CompilerOptions): boolean { + return options.allowUnreachableCode === false; + } + + export function unusedLabelIsError(options: CompilerOptions): boolean { + return options.allowUnusedLabels === false; + } + export function getAreDeclarationMapsEnabled(options: CompilerOptions) { return !!(options.declaration && options.declarationMap); } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 078bd600771d4..82b0a21d83817 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2238,7 +2238,8 @@ }, "Left side of comma operator is unused and has no side effects.": { "category": "Error", - "code": 2695 + "code": 2695, + "reportsUnnecessary": true }, "The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?": { "category": "Error", @@ -3668,7 +3669,8 @@ }, "Unreachable code detected.": { "category": "Error", - "code": 7027 + "code": 7027, + "reportsUnnecessary": true }, "Unused label.": { "category": "Error", diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index a286c9fae3566..489bc72db621f 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -2463,6 +2463,7 @@ namespace ts { if (node.symbolCount !== undefined) updated.symbolCount = node.symbolCount; if (node.parseDiagnostics !== undefined) updated.parseDiagnostics = node.parseDiagnostics; if (node.bindDiagnostics !== undefined) updated.bindDiagnostics = node.bindDiagnostics; + if (node.bindSuggestionDiagnostics !== undefined) updated.bindSuggestionDiagnostics = node.bindSuggestionDiagnostics; if (node.lineMap !== undefined) updated.lineMap = node.lineMap; if (node.classifiableNames !== undefined) updated.classifiableNames = node.classifiableNames; if (node.resolvedModules !== undefined) updated.resolvedModules = node.resolvedModules; diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 3a7adbc260915..e9c0ca66f1d8c 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -912,6 +912,7 @@ namespace ts { sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; + sourceFile.bindSuggestionDiagnostics = undefined; sourceFile.languageVersion = languageVersion; sourceFile.fileName = normalizePath(fileName); sourceFile.languageVariant = getLanguageVariant(scriptKind); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 19e526ba056fb..23e990d913e70 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2603,6 +2603,7 @@ namespace ts { // File-level diagnostics reported by the binder. /* @internal */ bindDiagnostics: Diagnostic[]; + /* @internal */ bindSuggestionDiagnostics?: Diagnostic[]; // File-level JSDoc diagnostics reported by the JSDoc parser /* @internal */ jsDocDiagnostics?: Diagnostic[]; diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 47f0a91b286d0..46df7fc09807c 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1317,8 +1317,13 @@ Actual: ${stringify(fullActual)}`); } private testDiagnostics(expected: ReadonlyArray, diagnostics: ReadonlyArray, category: string) { - assert.deepEqual(ts.realizeDiagnostics(diagnostics, ts.newLineCharacter), expected.map(e => ( - { message: e.message, category, code: e.code, ...ts.createTextSpanFromRange(e.range || this.getRanges()[0]) }))); + assert.deepEqual(ts.realizeDiagnostics(diagnostics, ts.newLineCharacter), expected.map((e): ts.RealizedDiagnostic => ({ + message: e.message, + category, + code: e.code, + ...ts.createTextSpanFromRange(e.range || this.getRanges()[0]), + reportsUnnecessary: e.reportsUnnecessary, + }))); } public verifyQuickInfoAt(markerName: string, expectedText: string, expectedDocumentation?: string) { @@ -4422,15 +4427,15 @@ namespace FourSlashInterface { this.state.verifyQuickInfoDisplayParts(kind, kindModifiers, textSpan, displayParts, documentation, tags); } - public getSyntacticDiagnostics(expected: ReadonlyArray) { + public getSyntacticDiagnostics(expected: ReadonlyArray) { this.state.getSyntacticDiagnostics(expected); } - public getSemanticDiagnostics(expected: ReadonlyArray) { + public getSemanticDiagnostics(expected: ReadonlyArray) { this.state.getSemanticDiagnostics(expected); } - public getSuggestionDiagnostics(expected: ReadonlyArray) { + public getSuggestionDiagnostics(expected: ReadonlyArray) { this.state.getSuggestionDiagnostics(expected); } @@ -4837,6 +4842,7 @@ namespace FourSlashInterface { message: string; range?: FourSlash.Range; code: number; + reportsUnnecessary?: true; } export interface GetEditsForFileRenameOptions { diff --git a/src/services/services.ts b/src/services/services.ts index 3fcd4e8e151f8..9b8d0e0464899 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -548,6 +548,7 @@ namespace ts { public syntacticDiagnostics: Diagnostic[]; public parseDiagnostics: Diagnostic[]; public bindDiagnostics: Diagnostic[]; + public bindSuggestionDiagnostics?: Diagnostic[]; public isDeclarationFile: boolean; public isDefaultLib: boolean; diff --git a/src/services/shims.ts b/src/services/shims.ts index d0735cc171766..c371533da0c1f 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -586,7 +586,7 @@ namespace ts { length: number; category: string; code: number; - unused?: {}; + reportsUnnecessary?: {}; } export function realizeDiagnostics(diagnostics: ReadonlyArray, newLine: string): RealizedDiagnostic[] { return diagnostics.map(d => realizeDiagnostic(d, newLine)); @@ -598,7 +598,8 @@ namespace ts { start: diagnostic.start, length: diagnostic.length, category: diagnosticCategoryName(diagnostic), - code: diagnostic.code + code: diagnostic.code, + reportsUnnecessary: diagnostic.reportsUnnecessary, }; } diff --git a/src/services/suggestionDiagnostics.ts b/src/services/suggestionDiagnostics.ts index 3135fdc368bbc..40ed7719c9fe4 100644 --- a/src/services/suggestionDiagnostics.ts +++ b/src/services/suggestionDiagnostics.ts @@ -60,6 +60,7 @@ namespace ts { } } + addRange(diags, sourceFile.bindSuggestionDiagnostics); return diags.concat(checker.getSuggestionDiagnostics(sourceFile)).sort((d1, d2) => d1.start - d2.start); } diff --git a/tests/baselines/reference/assignmentLHSIsValue.errors.txt b/tests/baselines/reference/assignmentLHSIsValue.errors.txt index 01de8d33441a5..3064d713a122a 100644 --- a/tests/baselines/reference/assignmentLHSIsValue.errors.txt +++ b/tests/baselines/reference/assignmentLHSIsValue.errors.txt @@ -13,7 +13,6 @@ tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(2 tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(30,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(31,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(32,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. -tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(35,3): error TS7028: Unused label. tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(35,9): error TS1128: Declaration or statement expected. tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(38,2): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(38,6): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. @@ -39,7 +38,7 @@ tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(6 tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(70,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. -==== tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts (39 errors) ==== +==== tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts (38 errors) ==== // expected error for all the LHS of assignments var value: any; @@ -105,8 +104,6 @@ tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(7 // object literals { a: 0} = value; - ~ -!!! error TS7028: Unused label. ~ !!! error TS1128: Declaration or statement expected. diff --git a/tests/baselines/reference/blockScopedBindingUsedBeforeDef.errors.txt b/tests/baselines/reference/blockScopedBindingUsedBeforeDef.errors.txt index 55b5c9dab2d21..3a55ebbfded50 100644 --- a/tests/baselines/reference/blockScopedBindingUsedBeforeDef.errors.txt +++ b/tests/baselines/reference/blockScopedBindingUsedBeforeDef.errors.txt @@ -1,10 +1,9 @@ tests/cases/compiler/blockScopedBindingUsedBeforeDef.ts(2,12): error TS2448: Block-scoped variable 'a' used before its declaration. tests/cases/compiler/blockScopedBindingUsedBeforeDef.ts(5,12): error TS2448: Block-scoped variable 'a' used before its declaration. -tests/cases/compiler/blockScopedBindingUsedBeforeDef.ts(5,35): error TS7027: Unreachable code detected. tests/cases/compiler/blockScopedBindingUsedBeforeDef.ts(8,7): error TS2448: Block-scoped variable 'b' used before its declaration. -==== tests/cases/compiler/blockScopedBindingUsedBeforeDef.ts (4 errors) ==== +==== tests/cases/compiler/blockScopedBindingUsedBeforeDef.ts (3 errors) ==== // 1: for (let {[a]: a} of [{ }]) continue; ~ @@ -14,8 +13,6 @@ tests/cases/compiler/blockScopedBindingUsedBeforeDef.ts(8,7): error TS2448: Bloc for (let {[a]: a} = { }; false; ) continue; ~ !!! error TS2448: Block-scoped variable 'a' used before its declaration. - ~~~~~~~~ -!!! error TS7027: Unreachable code detected. // 3: let {[b]: b} = { }; diff --git a/tests/baselines/reference/cf.errors.txt b/tests/baselines/reference/cf.errors.txt index 75b285c37c647..8f5f82f816962 100644 --- a/tests/baselines/reference/cf.errors.txt +++ b/tests/baselines/reference/cf.errors.txt @@ -53,7 +53,7 @@ tests/cases/compiler/cf.ts(36,13): error TS7027: Unreachable code detected. } catch (e) { x++; - } + } finally { x+=3; } diff --git a/tests/baselines/reference/cf.js b/tests/baselines/reference/cf.js index bc7e43a371ae2..7e95dca1944cc 100644 --- a/tests/baselines/reference/cf.js +++ b/tests/baselines/reference/cf.js @@ -39,7 +39,7 @@ function f() { } catch (e) { x++; - } + } finally { x+=3; } diff --git a/tests/baselines/reference/cf.symbols b/tests/baselines/reference/cf.symbols index 9c2d73f513429..d1f1c8392d1f8 100644 --- a/tests/baselines/reference/cf.symbols +++ b/tests/baselines/reference/cf.symbols @@ -77,7 +77,7 @@ function f() { x++; >x : Symbol(x, Decl(cf.ts, 2, 7)) - } + } finally { x+=3; >x : Symbol(x, Decl(cf.ts, 2, 7)) diff --git a/tests/baselines/reference/cf.types b/tests/baselines/reference/cf.types index b1b5b74c2f6a1..ba71e388dbdf1 100644 --- a/tests/baselines/reference/cf.types +++ b/tests/baselines/reference/cf.types @@ -121,7 +121,7 @@ function f() { x++; >x++ : number >x : number - } + } finally { x+=3; >x+=3 : number diff --git a/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.errors.txt b/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.errors.txt index 51b69f81620b9..3f806e2c1fd1b 100644 --- a/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.errors.txt +++ b/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.errors.txt @@ -14,7 +14,6 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(38,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(39,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(40,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(43,3): error TS7028: Unused label. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(43,10): error TS1128: Declaration or statement expected. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(46,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(52,15): error TS1034: 'super' must be followed by an argument list or member access. @@ -40,7 +39,7 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(85,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -==== tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts (40 errors) ==== +==== tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts (39 errors) ==== // expected error for all the LHS of compound assignments (arithmetic and addition) var value: any; @@ -116,8 +115,6 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm // object literals { a: 0 } **= value; - ~ -!!! error TS7028: Unused label. ~~~ !!! error TS1128: Declaration or statement expected. diff --git a/tests/baselines/reference/constDeclarations-scopes.errors.txt b/tests/baselines/reference/constDeclarations-scopes.errors.txt index 064ad9aaaf838..647807a6a3d51 100644 --- a/tests/baselines/reference/constDeclarations-scopes.errors.txt +++ b/tests/baselines/reference/constDeclarations-scopes.errors.txt @@ -1,9 +1,7 @@ -tests/cases/compiler/constDeclarations-scopes.ts(12,5): error TS7027: Unreachable code detected. -tests/cases/compiler/constDeclarations-scopes.ts(21,1): error TS7027: Unreachable code detected. tests/cases/compiler/constDeclarations-scopes.ts(27,1): error TS2410: The 'with' statement is not supported. All symbols in a 'with' block will have type 'any'. -==== tests/cases/compiler/constDeclarations-scopes.ts (3 errors) ==== +==== tests/cases/compiler/constDeclarations-scopes.ts (1 errors) ==== // global const c = "string"; @@ -16,8 +14,6 @@ tests/cases/compiler/constDeclarations-scopes.ts(27,1): error TS2410: The 'with' } else { const c = 0; - ~~~~~ -!!! error TS7027: Unreachable code detected. n = c; } @@ -27,8 +23,6 @@ tests/cases/compiler/constDeclarations-scopes.ts(27,1): error TS2410: The 'with' } do { - ~~ -!!! error TS7027: Unreachable code detected. const c = 0; n = c; } while (true); diff --git a/tests/baselines/reference/declarationEmitInvalidExport.errors.txt b/tests/baselines/reference/declarationEmitInvalidExport.errors.txt index 74c8fc6b0a5e1..45612eb4eb4df 100644 --- a/tests/baselines/reference/declarationEmitInvalidExport.errors.txt +++ b/tests/baselines/reference/declarationEmitInvalidExport.errors.txt @@ -1,13 +1,10 @@ -tests/cases/compiler/declarationEmitInvalidExport.ts(2,3): error TS7027: Unreachable code detected. tests/cases/compiler/declarationEmitInvalidExport.ts(4,30): error TS4081: Exported type alias 'MyClass' has or is using private name 'myClass'. tests/cases/compiler/declarationEmitInvalidExport.ts(5,1): error TS1128: Declaration or statement expected. -==== tests/cases/compiler/declarationEmitInvalidExport.ts (3 errors) ==== +==== tests/cases/compiler/declarationEmitInvalidExport.ts (2 errors) ==== if (false) { export var myClass = 0; - ~~~~~~ -!!! error TS7027: Unreachable code detected. } export type MyClass = typeof myClass; ~~~~~~~ diff --git a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.errors.txt b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.errors.txt index 1e471f9970c1c..fbf03bd2f231a 100644 --- a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.errors.txt +++ b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.errors.txt @@ -10,7 +10,6 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassS tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(12,13): error TS1005: ';' expected. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(13,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(16,5): error TS2304: Cannot find name 'set'. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(16,5): error TS7027: Unreachable code detected. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(16,9): error TS1005: ';' expected. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(16,9): error TS2304: Cannot find name 'C'. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(16,11): error TS2304: Cannot find name 'v'. @@ -38,7 +37,7 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassS tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(31,1): error TS1128: Declaration or statement expected. -==== tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts (38 errors) ==== +==== tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts (37 errors) ==== // error to use super calls outside a constructor class Base { @@ -79,8 +78,6 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassS set C(v) { ~~~ !!! error TS2304: Cannot find name 'set'. - ~~~ -!!! error TS7027: Unreachable code detected. ~ !!! error TS1005: ';' expected. ~ diff --git a/tests/baselines/reference/invalidContinueInDownlevelAsync.errors.txt b/tests/baselines/reference/invalidContinueInDownlevelAsync.errors.txt index ffdfee20090d5..f22d84f377996 100644 --- a/tests/baselines/reference/invalidContinueInDownlevelAsync.errors.txt +++ b/tests/baselines/reference/invalidContinueInDownlevelAsync.errors.txt @@ -1,8 +1,7 @@ tests/cases/compiler/invalidContinueInDownlevelAsync.ts(3,9): error TS1107: Jump target cannot cross function boundary. -tests/cases/compiler/invalidContinueInDownlevelAsync.ts(6,9): error TS7027: Unreachable code detected. -==== tests/cases/compiler/invalidContinueInDownlevelAsync.ts (2 errors) ==== +==== tests/cases/compiler/invalidContinueInDownlevelAsync.ts (1 errors) ==== async function func() { if (true) { continue; @@ -11,7 +10,5 @@ tests/cases/compiler/invalidContinueInDownlevelAsync.ts(6,9): error TS7027: Unre } else { await 1; - ~~~~~ -!!! error TS7027: Unreachable code detected. } } \ No newline at end of file diff --git a/tests/baselines/reference/invalidWhileBreakStatements.errors.txt b/tests/baselines/reference/invalidWhileBreakStatements.errors.txt index 7d4f86b3e9d15..54adc2856d7ef 100644 --- a/tests/baselines/reference/invalidWhileBreakStatements.errors.txt +++ b/tests/baselines/reference/invalidWhileBreakStatements.errors.txt @@ -1,14 +1,12 @@ tests/cases/conformance/statements/breakStatements/invalidWhileBreakStatements.ts(4,1): error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement. -tests/cases/conformance/statements/breakStatements/invalidWhileBreakStatements.ts(7,1): error TS7028: Unused label. tests/cases/conformance/statements/breakStatements/invalidWhileBreakStatements.ts(8,14): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. -tests/cases/conformance/statements/breakStatements/invalidWhileBreakStatements.ts(11,1): error TS7027: Unreachable code detected. tests/cases/conformance/statements/breakStatements/invalidWhileBreakStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. tests/cases/conformance/statements/breakStatements/invalidWhileBreakStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. tests/cases/conformance/statements/breakStatements/invalidWhileBreakStatements.ts(27,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. tests/cases/conformance/statements/breakStatements/invalidWhileBreakStatements.ts(37,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. -==== tests/cases/conformance/statements/breakStatements/invalidWhileBreakStatements.ts (8 errors) ==== +==== tests/cases/conformance/statements/breakStatements/invalidWhileBreakStatements.ts (6 errors) ==== // All errors // naked break not allowed @@ -18,16 +16,12 @@ tests/cases/conformance/statements/breakStatements/invalidWhileBreakStatements.t // non-existent label ONE: - ~~~ -!!! error TS7028: Unused label. while (true) break TWO; ~~~~~~~~~~ !!! error TS1116: A 'break' statement can only jump to a label of an enclosing statement. // break from inside function TWO: - ~~~ -!!! error TS7027: Unreachable code detected. while (true){ var x = () => { break TWO; diff --git a/tests/baselines/reference/nestedBlockScopedBindings13.errors.txt b/tests/baselines/reference/nestedBlockScopedBindings13.errors.txt deleted file mode 100644 index 0421583cff9b2..0000000000000 --- a/tests/baselines/reference/nestedBlockScopedBindings13.errors.txt +++ /dev/null @@ -1,18 +0,0 @@ -tests/cases/compiler/nestedBlockScopedBindings13.ts(2,5): error TS7027: Unreachable code detected. -tests/cases/compiler/nestedBlockScopedBindings13.ts(7,5): error TS7027: Unreachable code detected. - - -==== tests/cases/compiler/nestedBlockScopedBindings13.ts (2 errors) ==== - for (; false;) { - let x; - ~~~ -!!! error TS7027: Unreachable code detected. - () => x; - } - - for (; false;) { - let y; - ~~~ -!!! error TS7027: Unreachable code detected. - y = 1; - } \ No newline at end of file diff --git a/tests/baselines/reference/nestedBlockScopedBindings14.errors.txt b/tests/baselines/reference/nestedBlockScopedBindings14.errors.txt deleted file mode 100644 index 1b5babb4c25a0..0000000000000 --- a/tests/baselines/reference/nestedBlockScopedBindings14.errors.txt +++ /dev/null @@ -1,20 +0,0 @@ -tests/cases/compiler/nestedBlockScopedBindings14.ts(3,5): error TS7027: Unreachable code detected. -tests/cases/compiler/nestedBlockScopedBindings14.ts(9,5): error TS7027: Unreachable code detected. - - -==== tests/cases/compiler/nestedBlockScopedBindings14.ts (2 errors) ==== - var x; - for (; false;) { - let x; - ~~~ -!!! error TS7027: Unreachable code detected. - () => x; - } - - var y; - for (; false;) { - let y; - ~~~ -!!! error TS7027: Unreachable code detected. - y = 1; - } \ No newline at end of file diff --git a/tests/baselines/reference/nestedBlockScopedBindings15.errors.txt b/tests/baselines/reference/nestedBlockScopedBindings15.errors.txt deleted file mode 100644 index b60a502b528d7..0000000000000 --- a/tests/baselines/reference/nestedBlockScopedBindings15.errors.txt +++ /dev/null @@ -1,46 +0,0 @@ -tests/cases/compiler/nestedBlockScopedBindings15.ts(3,9): error TS7027: Unreachable code detected. -tests/cases/compiler/nestedBlockScopedBindings15.ts(10,9): error TS7027: Unreachable code detected. -tests/cases/compiler/nestedBlockScopedBindings15.ts(16,5): error TS7027: Unreachable code detected. -tests/cases/compiler/nestedBlockScopedBindings15.ts(25,5): error TS7027: Unreachable code detected. - - -==== tests/cases/compiler/nestedBlockScopedBindings15.ts (4 errors) ==== - for (; false;) { - { - let x; - ~~~ -!!! error TS7027: Unreachable code detected. - () => x; - } - } - - for (; false;) { - { - let y; - ~~~ -!!! error TS7027: Unreachable code detected. - y = 1; - } - } - - for (; false;) { - switch (1){ - ~~~~~~ -!!! error TS7027: Unreachable code detected. - case 1: - let z0; - () => z0; - break; - } - } - - for (; false;) { - switch (1){ - ~~~~~~ -!!! error TS7027: Unreachable code detected. - case 1: - let z; - z = 1; - break; - } - } \ No newline at end of file diff --git a/tests/baselines/reference/nestedBlockScopedBindings16.errors.txt b/tests/baselines/reference/nestedBlockScopedBindings16.errors.txt deleted file mode 100644 index 806f58231a060..0000000000000 --- a/tests/baselines/reference/nestedBlockScopedBindings16.errors.txt +++ /dev/null @@ -1,50 +0,0 @@ -tests/cases/compiler/nestedBlockScopedBindings16.ts(4,9): error TS7027: Unreachable code detected. -tests/cases/compiler/nestedBlockScopedBindings16.ts(12,9): error TS7027: Unreachable code detected. -tests/cases/compiler/nestedBlockScopedBindings16.ts(19,5): error TS7027: Unreachable code detected. -tests/cases/compiler/nestedBlockScopedBindings16.ts(29,5): error TS7027: Unreachable code detected. - - -==== tests/cases/compiler/nestedBlockScopedBindings16.ts (4 errors) ==== - var x; - for (; false;) { - { - let x; - ~~~ -!!! error TS7027: Unreachable code detected. - () => x; - } - } - - var y; - for (; false;) { - { - let y; - ~~~ -!!! error TS7027: Unreachable code detected. - y = 1; - } - } - - var z0; - for (; false;) { - switch (1){ - ~~~~~~ -!!! error TS7027: Unreachable code detected. - case 1: - let z0; - () => z0; - break; - } - } - - var z; - for (; false;) { - switch (1){ - ~~~~~~ -!!! error TS7027: Unreachable code detected. - case 1: - let z; - z = 1; - break; - } - } \ No newline at end of file diff --git a/tests/baselines/reference/nestedBlockScopedBindings5.errors.txt b/tests/baselines/reference/nestedBlockScopedBindings5.errors.txt deleted file mode 100644 index a40f6a29aead0..0000000000000 --- a/tests/baselines/reference/nestedBlockScopedBindings5.errors.txt +++ /dev/null @@ -1,92 +0,0 @@ -tests/cases/compiler/nestedBlockScopedBindings5.ts(37,9): error TS7027: Unreachable code detected. -tests/cases/compiler/nestedBlockScopedBindings5.ts(54,9): error TS7027: Unreachable code detected. -tests/cases/compiler/nestedBlockScopedBindings5.ts(71,9): error TS7027: Unreachable code detected. - - -==== tests/cases/compiler/nestedBlockScopedBindings5.ts (3 errors) ==== - function a0() { - for (let x in []) { - x = x + 1; - } - for (let x;;) { - x = x + 2; - } - } - - function a1() { - for (let x in []) { - x = x + 1; - () => x; - } - for (let x;;) { - x = x + 2; - } - } - - function a2() { - for (let x in []) { - x = x + 1; - } - for (let x;;) { - x = x + 2; - () => x; - } - } - - - function a3() { - for (let x in []) { - x = x + 1; - () => x; - } - for (let x;false;) { - x = x + 2; - ~ -!!! error TS7027: Unreachable code detected. - () => x; - } - switch (1) { - case 1: - let x; - () => x; - break; - } - - } - - function a4() { - for (let x in []) { - x = x + 1; - } - for (let x;false;) { - x = x + 2; - ~ -!!! error TS7027: Unreachable code detected. - } - switch (1) { - case 1: - let x; - () => x; - break; - } - - } - - function a5() { - let y; - for (let x in []) { - x = x + 1; - } - for (let x;false;) { - x = x + 2; - ~ -!!! error TS7027: Unreachable code detected. - () => x; - } - switch (1) { - case 1: - let x; - break; - } - - } \ No newline at end of file diff --git a/tests/baselines/reference/nestedBlockScopedBindings7.errors.txt b/tests/baselines/reference/nestedBlockScopedBindings7.errors.txt deleted file mode 100644 index 274ef8bf6c336..0000000000000 --- a/tests/baselines/reference/nestedBlockScopedBindings7.errors.txt +++ /dev/null @@ -1,16 +0,0 @@ -tests/cases/compiler/nestedBlockScopedBindings7.ts(2,5): error TS7027: Unreachable code detected. -tests/cases/compiler/nestedBlockScopedBindings7.ts(6,5): error TS7027: Unreachable code detected. - - -==== tests/cases/compiler/nestedBlockScopedBindings7.ts (2 errors) ==== - for (let x; false;) { - () => x; - ~ -!!! error TS7027: Unreachable code detected. - } - - for (let y; false;) { - y = 1; - ~ -!!! error TS7027: Unreachable code detected. - } \ No newline at end of file diff --git a/tests/baselines/reference/nestedBlockScopedBindings8.errors.txt b/tests/baselines/reference/nestedBlockScopedBindings8.errors.txt deleted file mode 100644 index 73f580ae3cb74..0000000000000 --- a/tests/baselines/reference/nestedBlockScopedBindings8.errors.txt +++ /dev/null @@ -1,18 +0,0 @@ -tests/cases/compiler/nestedBlockScopedBindings8.ts(3,5): error TS7027: Unreachable code detected. -tests/cases/compiler/nestedBlockScopedBindings8.ts(8,5): error TS7027: Unreachable code detected. - - -==== tests/cases/compiler/nestedBlockScopedBindings8.ts (2 errors) ==== - var x; - for (let x; false; ) { - () => x; - ~ -!!! error TS7027: Unreachable code detected. - } - - var y; - for (let y; false; ) { - y = 1; - ~ -!!! error TS7027: Unreachable code detected. - } \ No newline at end of file diff --git a/tests/baselines/reference/parserErrorRecovery_ModuleElement1.errors.txt b/tests/baselines/reference/parserErrorRecovery_ModuleElement1.errors.txt index 05b31b7af8e56..4b8be3e17ad6e 100644 --- a/tests/baselines/reference/parserErrorRecovery_ModuleElement1.errors.txt +++ b/tests/baselines/reference/parserErrorRecovery_ModuleElement1.errors.txt @@ -1,16 +1,13 @@ tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ModuleElements/parserErrorRecovery_ModuleElement1.ts(2,1): error TS1128: Declaration or statement expected. -tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ModuleElements/parserErrorRecovery_ModuleElement1.ts(3,1): error TS7027: Unreachable code detected. tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ModuleElements/parserErrorRecovery_ModuleElement1.ts(4,1): error TS1128: Declaration or statement expected. -==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ModuleElements/parserErrorRecovery_ModuleElement1.ts (3 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ModuleElements/parserErrorRecovery_ModuleElement1.ts (2 errors) ==== return foo; } ~ !!! error TS1128: Declaration or statement expected. return bar; - ~~~~~~ -!!! error TS7027: Unreachable code detected. } ~ !!! error TS1128: Declaration or statement expected. \ No newline at end of file diff --git a/tests/baselines/reference/parserLabeledStatement1.d.errors.txt b/tests/baselines/reference/parserLabeledStatement1.d.errors.txt index 2ce51b0bb4c6f..11de61548a366 100644 --- a/tests/baselines/reference/parserLabeledStatement1.d.errors.txt +++ b/tests/baselines/reference/parserLabeledStatement1.d.errors.txt @@ -1,14 +1,11 @@ tests/cases/conformance/parser/ecmascript5/Statements/parserLabeledStatement1.d.ts(1,1): error TS1036: Statements are not allowed in ambient contexts. -tests/cases/conformance/parser/ecmascript5/Statements/parserLabeledStatement1.d.ts(1,1): error TS7028: Unused label. tests/cases/conformance/parser/ecmascript5/Statements/parserLabeledStatement1.d.ts(2,3): error TS2304: Cannot find name 'bar'. -==== tests/cases/conformance/parser/ecmascript5/Statements/parserLabeledStatement1.d.ts (3 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/Statements/parserLabeledStatement1.d.ts (2 errors) ==== foo: ~~~ !!! error TS1036: Statements are not allowed in ambient contexts. - ~~~ -!!! error TS7028: Unused label. bar(); ~~~ !!! error TS2304: Cannot find name 'bar'. \ No newline at end of file diff --git a/tests/baselines/reference/parser_breakTarget5.errors.txt b/tests/baselines/reference/parser_breakTarget5.errors.txt index 5943649c97b45..8221cbebb4c70 100644 --- a/tests/baselines/reference/parser_breakTarget5.errors.txt +++ b/tests/baselines/reference/parser_breakTarget5.errors.txt @@ -1,11 +1,8 @@ -tests/cases/conformance/parser/ecmascript5/Statements/BreakStatements/parser_breakTarget5.ts(1,1): error TS7028: Unused label. tests/cases/conformance/parser/ecmascript5/Statements/BreakStatements/parser_breakTarget5.ts(5,7): error TS1107: Jump target cannot cross function boundary. -==== tests/cases/conformance/parser/ecmascript5/Statements/BreakStatements/parser_breakTarget5.ts (2 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/Statements/BreakStatements/parser_breakTarget5.ts (1 errors) ==== target: - ~~~~~~ -!!! error TS7028: Unused label. while (true) { function f() { while (true) { diff --git a/tests/baselines/reference/parser_continueNotInIterationStatement4.errors.txt b/tests/baselines/reference/parser_continueNotInIterationStatement4.errors.txt index 9439225956897..efade17a52a03 100644 --- a/tests/baselines/reference/parser_continueNotInIterationStatement4.errors.txt +++ b/tests/baselines/reference/parser_continueNotInIterationStatement4.errors.txt @@ -1,11 +1,8 @@ -tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueNotInIterationStatement4.ts(1,1): error TS7028: Unused label. tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueNotInIterationStatement4.ts(4,5): error TS1107: Jump target cannot cross function boundary. -==== tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueNotInIterationStatement4.ts (2 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueNotInIterationStatement4.ts (1 errors) ==== TWO: - ~~~ -!!! error TS7028: Unused label. while (true){ var x = () => { continue TWO; diff --git a/tests/baselines/reference/parser_continueTarget5.errors.txt b/tests/baselines/reference/parser_continueTarget5.errors.txt index b9b1f2edb945d..ffeee7a07b311 100644 --- a/tests/baselines/reference/parser_continueTarget5.errors.txt +++ b/tests/baselines/reference/parser_continueTarget5.errors.txt @@ -1,11 +1,8 @@ -tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueTarget5.ts(1,1): error TS7028: Unused label. tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueTarget5.ts(5,7): error TS1107: Jump target cannot cross function boundary. -==== tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueTarget5.ts (2 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueTarget5.ts (1 errors) ==== target: - ~~~~~~ -!!! error TS7028: Unused label. while (true) { function f() { while (true) { diff --git a/tests/baselines/reference/parser_duplicateLabel1.errors.txt b/tests/baselines/reference/parser_duplicateLabel1.errors.txt index 95c0ad9a290d5..dee0d5d40e681 100644 --- a/tests/baselines/reference/parser_duplicateLabel1.errors.txt +++ b/tests/baselines/reference/parser_duplicateLabel1.errors.txt @@ -1,16 +1,10 @@ -tests/cases/conformance/parser/ecmascript5/Statements/LabeledStatements/parser_duplicateLabel1.ts(1,1): error TS7028: Unused label. tests/cases/conformance/parser/ecmascript5/Statements/LabeledStatements/parser_duplicateLabel1.ts(2,1): error TS1114: Duplicate label 'target'. -tests/cases/conformance/parser/ecmascript5/Statements/LabeledStatements/parser_duplicateLabel1.ts(2,1): error TS7028: Unused label. -==== tests/cases/conformance/parser/ecmascript5/Statements/LabeledStatements/parser_duplicateLabel1.ts (3 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/Statements/LabeledStatements/parser_duplicateLabel1.ts (1 errors) ==== target: - ~~~~~~ -!!! error TS7028: Unused label. target: ~~~~~~ !!! error TS1114: Duplicate label 'target'. - ~~~~~~ -!!! error TS7028: Unused label. while (true) { } \ No newline at end of file diff --git a/tests/baselines/reference/parser_duplicateLabel2.errors.txt b/tests/baselines/reference/parser_duplicateLabel2.errors.txt index 6d42b8c34fecf..60a2c2659c3ad 100644 --- a/tests/baselines/reference/parser_duplicateLabel2.errors.txt +++ b/tests/baselines/reference/parser_duplicateLabel2.errors.txt @@ -1,18 +1,12 @@ -tests/cases/conformance/parser/ecmascript5/Statements/LabeledStatements/parser_duplicateLabel2.ts(1,1): error TS7028: Unused label. tests/cases/conformance/parser/ecmascript5/Statements/LabeledStatements/parser_duplicateLabel2.ts(3,3): error TS1114: Duplicate label 'target'. -tests/cases/conformance/parser/ecmascript5/Statements/LabeledStatements/parser_duplicateLabel2.ts(3,3): error TS7028: Unused label. -==== tests/cases/conformance/parser/ecmascript5/Statements/LabeledStatements/parser_duplicateLabel2.ts (3 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/Statements/LabeledStatements/parser_duplicateLabel2.ts (1 errors) ==== target: - ~~~~~~ -!!! error TS7028: Unused label. while (true) { target: ~~~~~~ !!! error TS1114: Duplicate label 'target'. - ~~~~~~ -!!! error TS7028: Unused label. while (true) { } } \ No newline at end of file diff --git a/tests/baselines/reference/recursiveLetConst.errors.txt b/tests/baselines/reference/recursiveLetConst.errors.txt index 88ecb379e5ef8..b02d0819a3f46 100644 --- a/tests/baselines/reference/recursiveLetConst.errors.txt +++ b/tests/baselines/reference/recursiveLetConst.errors.txt @@ -3,7 +3,6 @@ tests/cases/compiler/recursiveLetConst.ts(3,12): error TS2448: Block-scoped vari tests/cases/compiler/recursiveLetConst.ts(4,11): error TS2448: Block-scoped variable 'y' used before its declaration. tests/cases/compiler/recursiveLetConst.ts(5,14): error TS2448: Block-scoped variable 'y1' used before its declaration. tests/cases/compiler/recursiveLetConst.ts(6,14): error TS2448: Block-scoped variable 'v' used before its declaration. -tests/cases/compiler/recursiveLetConst.ts(7,1): error TS7027: Unreachable code detected. tests/cases/compiler/recursiveLetConst.ts(7,16): error TS2448: Block-scoped variable 'v' used before its declaration. tests/cases/compiler/recursiveLetConst.ts(8,15): error TS2448: Block-scoped variable 'v' used before its declaration. tests/cases/compiler/recursiveLetConst.ts(9,15): error TS2448: Block-scoped variable 'v' used before its declaration. @@ -11,7 +10,7 @@ tests/cases/compiler/recursiveLetConst.ts(10,17): error TS2448: Block-scoped var tests/cases/compiler/recursiveLetConst.ts(11,11): error TS2448: Block-scoped variable 'x2' used before its declaration. -==== tests/cases/compiler/recursiveLetConst.ts (11 errors) ==== +==== tests/cases/compiler/recursiveLetConst.ts (10 errors) ==== 'use strict' let x = x + 1; ~ @@ -29,8 +28,6 @@ tests/cases/compiler/recursiveLetConst.ts(11,11): error TS2448: Block-scoped var ~ !!! error TS2448: Block-scoped variable 'v' used before its declaration. for (let [v] = v; ;) { } - ~~~ -!!! error TS7027: Unreachable code detected. ~ !!! error TS2448: Block-scoped variable 'v' used before its declaration. for (let v in v) { } diff --git a/tests/baselines/reference/recursiveNamedLambdaCall.errors.txt b/tests/baselines/reference/recursiveNamedLambdaCall.errors.txt index 04ddc371ac710..7729d1e780fad 100644 --- a/tests/baselines/reference/recursiveNamedLambdaCall.errors.txt +++ b/tests/baselines/reference/recursiveNamedLambdaCall.errors.txt @@ -1,12 +1,11 @@ tests/cases/compiler/recursiveNamedLambdaCall.ts(3,8): error TS2304: Cannot find name 'top'. tests/cases/compiler/recursiveNamedLambdaCall.ts(3,15): error TS2304: Cannot find name 'top'. -tests/cases/compiler/recursiveNamedLambdaCall.ts(7,6): error TS7027: Unreachable code detected. tests/cases/compiler/recursiveNamedLambdaCall.ts(8,7): error TS2304: Cannot find name 'top'. tests/cases/compiler/recursiveNamedLambdaCall.ts(10,14): error TS2304: Cannot find name 'setTimeout'. tests/cases/compiler/recursiveNamedLambdaCall.ts(14,6): error TS2304: Cannot find name 'detach'. -==== tests/cases/compiler/recursiveNamedLambdaCall.ts (6 errors) ==== +==== tests/cases/compiler/recursiveNamedLambdaCall.ts (5 errors) ==== var promise = function( obj ) { if ( top && top.doScroll ) { @@ -18,8 +17,6 @@ tests/cases/compiler/recursiveNamedLambdaCall.ts(14,6): error TS2304: Cannot fin if ( false ) { try { - ~~~ -!!! error TS7027: Unreachable code detected. top.doScroll("left"); ~~~ !!! error TS2304: Cannot find name 'top'. diff --git a/tests/baselines/reference/reservedWords2.errors.txt b/tests/baselines/reference/reservedWords2.errors.txt index f1d781ed59ed7..0760e1e2566e3 100644 --- a/tests/baselines/reference/reservedWords2.errors.txt +++ b/tests/baselines/reference/reservedWords2.errors.txt @@ -15,7 +15,6 @@ tests/cases/compiler/reservedWords2.ts(5,9): error TS2567: Enum declarations can tests/cases/compiler/reservedWords2.ts(5,10): error TS1003: Identifier expected. tests/cases/compiler/reservedWords2.ts(5,18): error TS1005: '=>' expected. tests/cases/compiler/reservedWords2.ts(6,1): error TS2304: Cannot find name 'module'. -tests/cases/compiler/reservedWords2.ts(6,1): error TS7027: Unreachable code detected. tests/cases/compiler/reservedWords2.ts(6,8): error TS1005: ';' expected. tests/cases/compiler/reservedWords2.ts(7,11): error TS2300: Duplicate identifier '(Missing)'. tests/cases/compiler/reservedWords2.ts(7,11): error TS1005: ':' expected. @@ -33,7 +32,7 @@ tests/cases/compiler/reservedWords2.ts(10,5): error TS2567: Enum declarations ca tests/cases/compiler/reservedWords2.ts(10,6): error TS1003: Identifier expected. -==== tests/cases/compiler/reservedWords2.ts (33 errors) ==== +==== tests/cases/compiler/reservedWords2.ts (32 errors) ==== import while = require("dfdf"); ~~~~~ !!! error TS1109: Expression expected. @@ -74,8 +73,6 @@ tests/cases/compiler/reservedWords2.ts(10,6): error TS1003: Identifier expected. module void {} ~~~~~~ !!! error TS2304: Cannot find name 'module'. - ~~~~~~ -!!! error TS7027: Unreachable code detected. ~~~~ !!! error TS1005: ';' expected. var {while, return} = { while: 1, return: 2 }; diff --git a/tests/baselines/reference/scanner10.1.1-8gs.errors.txt b/tests/baselines/reference/scanner10.1.1-8gs.errors.txt index 6e75f195c2634..512da96548682 100644 --- a/tests/baselines/reference/scanner10.1.1-8gs.errors.txt +++ b/tests/baselines/reference/scanner10.1.1-8gs.errors.txt @@ -1,9 +1,8 @@ tests/cases/conformance/scanner/ecmascript5/scanner10.1.1-8gs.ts(16,7): error TS2304: Cannot find name 'NotEarlyError'. -tests/cases/conformance/scanner/ecmascript5/scanner10.1.1-8gs.ts(17,1): error TS7027: Unreachable code detected. tests/cases/conformance/scanner/ecmascript5/scanner10.1.1-8gs.ts(17,5): error TS1212: Identifier expected. 'public' is a reserved word in strict mode. -==== tests/cases/conformance/scanner/ecmascript5/scanner10.1.1-8gs.ts (3 errors) ==== +==== tests/cases/conformance/scanner/ecmascript5/scanner10.1.1-8gs.ts (2 errors) ==== /// Copyright (c) 2012 Ecma International. All rights reserved. /// Ecma International makes this code available under the terms and conditions set /// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the @@ -23,8 +22,6 @@ tests/cases/conformance/scanner/ecmascript5/scanner10.1.1-8gs.ts(17,5): error TS ~~~~~~~~~~~~~ !!! error TS2304: Cannot find name 'NotEarlyError'. var public = 1; - ~~~ -!!! error TS7027: Unreachable code detected. ~~~~~~ !!! error TS1212: Identifier expected. 'public' is a reserved word in strict mode. \ No newline at end of file diff --git a/tests/baselines/reference/setterWithReturn.errors.txt b/tests/baselines/reference/setterWithReturn.errors.txt index a0f04506a710b..deb0fa6fc3257 100644 --- a/tests/baselines/reference/setterWithReturn.errors.txt +++ b/tests/baselines/reference/setterWithReturn.errors.txt @@ -1,10 +1,9 @@ tests/cases/compiler/setterWithReturn.ts(2,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/setterWithReturn.ts(4,13): error TS2408: Setters cannot return a value. -tests/cases/compiler/setterWithReturn.ts(7,13): error TS7027: Unreachable code detected. tests/cases/compiler/setterWithReturn.ts(7,13): error TS2408: Setters cannot return a value. -==== tests/cases/compiler/setterWithReturn.ts (4 errors) ==== +==== tests/cases/compiler/setterWithReturn.ts (3 errors) ==== class C234 { public set p1(arg1) { ~~ @@ -16,8 +15,6 @@ tests/cases/compiler/setterWithReturn.ts(7,13): error TS2408: Setters cannot ret } else { return 0; - ~~~~~~ -!!! error TS7027: Unreachable code detected. ~~~~~~~~~ !!! error TS2408: Setters cannot return a value. } diff --git a/tests/baselines/reference/sourceMapValidationFor.errors.txt b/tests/baselines/reference/sourceMapValidationFor.errors.txt index ffc981648d696..75139bcb12dbc 100644 --- a/tests/baselines/reference/sourceMapValidationFor.errors.txt +++ b/tests/baselines/reference/sourceMapValidationFor.errors.txt @@ -1,8 +1,7 @@ -tests/cases/compiler/sourceMapValidationFor.ts(20,1): error TS7027: Unreachable code detected. tests/cases/compiler/sourceMapValidationFor.ts(32,21): error TS2695: Left side of comma operator is unused and has no side effects. -==== tests/cases/compiler/sourceMapValidationFor.ts (2 errors) ==== +==== tests/cases/compiler/sourceMapValidationFor.ts (1 errors) ==== for (var i = 0; i < 10; i++) { WScript.Echo("i: " + i); } @@ -23,8 +22,6 @@ tests/cases/compiler/sourceMapValidationFor.ts(32,21): error TS2695: Left side o for (var k = 0;; k++) { } for (k = 0;; k++) - ~~~ -!!! error TS7027: Unreachable code detected. { } for (; k < 10; k++) { diff --git a/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt b/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt index 56ac090c02c9f..797c6877e21b5 100644 --- a/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt +++ b/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt @@ -93,13 +93,12 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(172,39): e tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(172,40): error TS1128: Declaration or statement expected. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(172,42): error TS2693: 'number' only refers to a type, but is being used as a value here. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(172,49): error TS1005: ';' expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(175,1): error TS7027: Unreachable code detected. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(175,29): error TS2304: Cannot find name 'm'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(175,32): error TS1005: ';' expected. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(175,35): error TS2304: Cannot find name 'm'. -==== tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts (65 errors) ==== +==== tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts (64 errors) ==== class C { n: number; explicitThis(this: this, m: number): number { @@ -431,8 +430,6 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(175,35): e // can't name parameters 'this' in a lambda. c.explicitProperty = (this, m) => m + this.n; - ~ -!!! error TS7027: Unreachable code detected. ~ !!! error TS2304: Cannot find name 'm'. ~~ diff --git a/tests/baselines/reference/throwWithoutNewLine2.errors.txt b/tests/baselines/reference/throwWithoutNewLine2.errors.txt index 83f4e4cc24627..6930d240e7b82 100644 --- a/tests/baselines/reference/throwWithoutNewLine2.errors.txt +++ b/tests/baselines/reference/throwWithoutNewLine2.errors.txt @@ -1,14 +1,11 @@ tests/cases/compiler/throwWithoutNewLine2.ts(1,6): error TS1142: Line break not permitted here. tests/cases/compiler/throwWithoutNewLine2.ts(2,1): error TS2304: Cannot find name 'a'. -tests/cases/compiler/throwWithoutNewLine2.ts(2,1): error TS7027: Unreachable code detected. -==== tests/cases/compiler/throwWithoutNewLine2.ts (3 errors) ==== +==== tests/cases/compiler/throwWithoutNewLine2.ts (2 errors) ==== throw !!! error TS1142: Line break not permitted here. a; ~ -!!! error TS2304: Cannot find name 'a'. - ~ -!!! error TS7027: Unreachable code detected. \ No newline at end of file +!!! error TS2304: Cannot find name 'a'. \ No newline at end of file diff --git a/tests/baselines/reference/typeGuardFunctionErrors.errors.txt b/tests/baselines/reference/typeGuardFunctionErrors.errors.txt index 52e8b3bf81bd2..4be44cc799a1a 100644 --- a/tests/baselines/reference/typeGuardFunctionErrors.errors.txt +++ b/tests/baselines/reference/typeGuardFunctionErrors.errors.txt @@ -8,7 +8,6 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(21,33) tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(25,33): error TS1225: Cannot find parameter 'x'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(29,10): error TS2391: Function implementation is missing or not immediately following the declaration. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(30,5): error TS1131: Property or signature expected. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(30,5): error TS7027: Unreachable code detected. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(31,1): error TS1128: Declaration or statement expected. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(33,38): error TS1225: Cannot find parameter 'x'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(37,51): error TS2677: A type predicate's type must be assignable to its parameter's type. @@ -71,7 +70,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(166,45 tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(166,54): error TS2344: Type 'number' does not satisfy the constraint 'Foo'. -==== tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts (57 errors) ==== +==== tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts (56 errors) ==== class A { ~ !!! error TS2300: Duplicate identifier 'A'. @@ -122,8 +121,6 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(166,54 return true; ~~~~~~ !!! error TS1131: Property or signature expected. - ~~~~~~ -!!! error TS7027: Unreachable code detected. } ~ !!! error TS1128: Declaration or statement expected. diff --git a/tests/baselines/reference/typeofOperatorWithAnyOtherType.errors.txt b/tests/baselines/reference/typeofOperatorWithAnyOtherType.errors.txt index 9357cf4e4cc36..4251ce08ad957 100644 --- a/tests/baselines/reference/typeofOperatorWithAnyOtherType.errors.txt +++ b/tests/baselines/reference/typeofOperatorWithAnyOtherType.errors.txt @@ -2,16 +2,9 @@ tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperator tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(47,32): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(48,32): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(58,1): error TS2695: Left side of comma operator is unused and has no side effects. -tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(68,1): error TS7028: Unused label. -tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(69,1): error TS7028: Unused label. -tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(70,1): error TS7028: Unused label. -tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(71,1): error TS7028: Unused label. -tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(72,1): error TS7028: Unused label. -tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(73,1): error TS7028: Unused label. -tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(74,1): error TS7028: Unused label. -==== tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts (11 errors) ==== +==== tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts (4 errors) ==== // typeof operator on any type var ANY: any; @@ -88,23 +81,9 @@ tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperator var x: any[]; var r: () => any; z: typeof ANY; - ~ -!!! error TS7028: Unused label. x: typeof ANY2; - ~ -!!! error TS7028: Unused label. r: typeof foo; - ~ -!!! error TS7028: Unused label. z: typeof objA.a; - ~ -!!! error TS7028: Unused label. z: typeof A.foo; - ~ -!!! error TS7028: Unused label. z: typeof M.n; - ~ -!!! error TS7028: Unused label. - z: typeof obj1.x; - ~ -!!! error TS7028: Unused label. \ No newline at end of file + z: typeof obj1.x; \ No newline at end of file diff --git a/tests/baselines/reference/typeofOperatorWithStringType.errors.txt b/tests/baselines/reference/typeofOperatorWithStringType.errors.txt index 6d01d397ab6c6..1aa3905d1496c 100644 --- a/tests/baselines/reference/typeofOperatorWithStringType.errors.txt +++ b/tests/baselines/reference/typeofOperatorWithStringType.errors.txt @@ -1,14 +1,7 @@ tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithStringType.ts(44,1): error TS2695: Left side of comma operator is unused and has no side effects. -tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithStringType.ts(50,1): error TS7028: Unused label. -tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithStringType.ts(51,1): error TS7028: Unused label. -tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithStringType.ts(52,1): error TS7028: Unused label. -tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithStringType.ts(54,1): error TS7028: Unused label. -tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithStringType.ts(55,1): error TS7028: Unused label. -tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithStringType.ts(56,1): error TS7028: Unused label. -tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithStringType.ts(57,1): error TS7028: Unused label. -==== tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithStringType.ts (8 errors) ==== +==== tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithStringType.ts (1 errors) ==== // typeof operator on string type var STRING: string; var STRING1: string[] = ["", "abc"]; @@ -61,24 +54,10 @@ tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperator var x: string[]; var r: () => string; z: typeof STRING; - ~ -!!! error TS7028: Unused label. x: typeof STRING1; - ~ -!!! error TS7028: Unused label. r: typeof foo; - ~ -!!! error TS7028: Unused label. var y = { a: "", b: "" }; z: typeof y.a; - ~ -!!! error TS7028: Unused label. z: typeof objA.a; - ~ -!!! error TS7028: Unused label. z: typeof A.foo; - ~ -!!! error TS7028: Unused label. - z: typeof M.n; - ~ -!!! error TS7028: Unused label. \ No newline at end of file + z: typeof M.n; \ No newline at end of file diff --git a/tests/baselines/reference/undeclaredVarEmit.errors.txt b/tests/baselines/reference/undeclaredVarEmit.errors.txt index bbf508ab005bc..ff5d2ef7e9eec 100644 --- a/tests/baselines/reference/undeclaredVarEmit.errors.txt +++ b/tests/baselines/reference/undeclaredVarEmit.errors.txt @@ -1,10 +1,7 @@ -tests/cases/compiler/undeclaredVarEmit.ts(1,1): error TS7028: Unused label. tests/cases/compiler/undeclaredVarEmit.ts(1,4): error TS2693: 'number' only refers to a type, but is being used as a value here. -==== tests/cases/compiler/undeclaredVarEmit.ts (2 errors) ==== +==== tests/cases/compiler/undeclaredVarEmit.ts (1 errors) ==== f: number; - ~ -!!! error TS7028: Unused label. ~~~~~~ !!! error TS2693: 'number' only refers to a type, but is being used as a value here. \ No newline at end of file diff --git a/tests/baselines/reference/validMultipleVariableDeclarations.errors.txt b/tests/baselines/reference/validMultipleVariableDeclarations.errors.txt deleted file mode 100644 index 8f751e9efeead..0000000000000 --- a/tests/baselines/reference/validMultipleVariableDeclarations.errors.txt +++ /dev/null @@ -1,45 +0,0 @@ -tests/cases/conformance/statements/VariableStatements/validMultipleVariableDeclarations.ts(9,1): error TS7027: Unreachable code detected. - - -==== tests/cases/conformance/statements/VariableStatements/validMultipleVariableDeclarations.ts (1 errors) ==== - // all expected to be valid - - var x: number; - var x = 2; - if (true) { - var x = 3; - for (var x = 0; ;) { } - } - var x = undefined; - ~~~ -!!! error TS7027: Unreachable code detected. - - // new declaration space, making redeclaring x as a string valid - function declSpace() { - var x = 'this is a string'; - } - - interface Point { x: number; y: number; } - - var p: Point; - var p = { x: 1, y: 2 }; - var p: Point = { x: 0, y: undefined }; - var p = { x: 1, y: undefined }; - var p: { x: number; y: number; } = { x: 1, y: 2 }; - var p = <{ x: number; y: number; }>{ x: 0, y: undefined }; - var p: typeof p; - - var fn = function (s: string) { return 42; } - var fn = (s: string) => 3; - var fn: (s: string) => number; - var fn: { (s: string): number }; - var fn = <(s: string) => number> null; - var fn: typeof fn; - - var a: string[]; - var a = ['a', 'b'] - var a = []; - var a: string[] = []; - var a = new Array(); - var a: typeof a; - \ No newline at end of file diff --git a/tests/baselines/reference/whileContinueStatements.errors.txt b/tests/baselines/reference/whileContinueStatements.errors.txt deleted file mode 100644 index c2009b02600ec..0000000000000 --- a/tests/baselines/reference/whileContinueStatements.errors.txt +++ /dev/null @@ -1,59 +0,0 @@ -tests/cases/conformance/statements/continueStatements/whileContinueStatements.ts(5,1): error TS7027: Unreachable code detected. - - -==== tests/cases/conformance/statements/continueStatements/whileContinueStatements.ts (1 errors) ==== - while(true) { - continue; - } - - while (true) { - ~~~~~ -!!! error TS7027: Unreachable code detected. - if (true) { - continue; - } - } - - ONE: - - while (true) { - continue ONE; - } - - TWO: - THREE: - while (true) { - continue THREE; - } - - FOUR: - while (true) { - FIVE: - while (true) { - continue FOUR; - } - } - - while (true) { - SIX: - while (true) - continue SIX; - } - - SEVEN: - while (true) - while (true) - while (true) - continue SEVEN; - - EIGHT: - while (true) { - var fn = function () { } - continue EIGHT; - } - - NINE: - while (true) { - if (true) { continue NINE; } - } - \ No newline at end of file diff --git a/tests/cases/compiler/cf.ts b/tests/cases/compiler/cf.ts index a37f626cd898a..4b1afcbf00036 100644 --- a/tests/cases/compiler/cf.ts +++ b/tests/cases/compiler/cf.ts @@ -1,3 +1,4 @@ +// @allowUnreachableCode: false function f() { var z; var x=10; @@ -38,7 +39,7 @@ function f() { } catch (e) { x++; - } + } finally { x+=3; } diff --git a/tests/cases/compiler/commaOperator1.ts b/tests/cases/compiler/commaOperator1.ts index 0cba7f1cd53f6..2a51e06eadce0 100644 --- a/tests/cases/compiler/commaOperator1.ts +++ b/tests/cases/compiler/commaOperator1.ts @@ -1,3 +1,4 @@ +// @allowUnreachableCode: false var v1 = ((1, 2, 3), 4, 5, (6, 7)); function f1() { var a = 1; diff --git a/tests/cases/compiler/commaOperatorLeftSideUnused.ts b/tests/cases/compiler/commaOperatorLeftSideUnused.ts index b4ac6ac1a178b..e5bab897afa76 100644 --- a/tests/cases/compiler/commaOperatorLeftSideUnused.ts +++ b/tests/cases/compiler/commaOperatorLeftSideUnused.ts @@ -1,3 +1,4 @@ +// @allowUnreachableCode: false var xx: any; var yy: any; diff --git a/tests/cases/compiler/evalAfter0.ts b/tests/cases/compiler/evalAfter0.ts index 2245150ce6ab3..8b9ac51d5d473 100644 --- a/tests/cases/compiler/evalAfter0.ts +++ b/tests/cases/compiler/evalAfter0.ts @@ -1,3 +1,4 @@ +// @allowUnreachableCode: false (0,eval)("10"); // fine: special case for eval declare var eva; diff --git a/tests/cases/compiler/jsFileCompilationBindErrors.ts b/tests/cases/compiler/jsFileCompilationBindErrors.ts index 7c43b329a4740..dc34a38afffe8 100644 --- a/tests/cases/compiler/jsFileCompilationBindErrors.ts +++ b/tests/cases/compiler/jsFileCompilationBindErrors.ts @@ -1,6 +1,8 @@ // @allowJs: true // @checkJs: true // @noEmit: true +// @allowUnreachableCode: false + // @filename: a.js let C = "sss"; let C = 0; // Error: Cannot redeclare block-scoped variable 'C'. diff --git a/tests/cases/compiler/jsFileCompilationBindReachabilityErrors.ts b/tests/cases/compiler/jsFileCompilationBindReachabilityErrors.ts index e92732313163a..29dfd68bb0411 100644 --- a/tests/cases/compiler/jsFileCompilationBindReachabilityErrors.ts +++ b/tests/cases/compiler/jsFileCompilationBindReachabilityErrors.ts @@ -1,8 +1,11 @@ // @allowJs: true // @checkJs: true // @noEmit: true -// @filename: a.js // @noFallthroughCasesInSwitch: true +// @allowUnreachableCode: false +// @allowUnusedLabels: false + +// @filename: a.js function foo(a, b) { switch (a) { case 10: diff --git a/tests/cases/compiler/unreachableJavascriptChecked.ts b/tests/cases/compiler/unreachableJavascriptChecked.ts index 4db98c4c8c4e1..afddcba6a23b1 100644 --- a/tests/cases/compiler/unreachableJavascriptChecked.ts +++ b/tests/cases/compiler/unreachableJavascriptChecked.ts @@ -2,6 +2,7 @@ // @allowJs: true // @checkJs: true // @outDir: out +// @allowUnreachableCode: false function unreachable() { return 1; return 2; diff --git a/tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts b/tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts index 176c2043344a4..2964561dc6302 100644 --- a/tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts +++ b/tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts @@ -1,3 +1,4 @@ +// @allowUnreachableCode: false // expected error for all the LHS of compound assignments (arithmetic and addition) var value: any; diff --git a/tests/cases/conformance/expressions/commaOperator/commaOperatorWithoutOperand.ts b/tests/cases/conformance/expressions/commaOperator/commaOperatorWithoutOperand.ts index e52e6e30bfa72..dce2222c967c4 100644 --- a/tests/cases/conformance/expressions/commaOperator/commaOperatorWithoutOperand.ts +++ b/tests/cases/conformance/expressions/commaOperator/commaOperatorWithoutOperand.ts @@ -1,3 +1,4 @@ +// @allowUnreachableCode: false var ANY: any; var BOOLEAN: boolean; var NUMBER: number; diff --git a/tests/cases/fourslash/codeFixUnreachableCode.ts b/tests/cases/fourslash/codeFixUnreachableCode.ts index bbe716e792e35..5f70d51c1ee10 100644 --- a/tests/cases/fourslash/codeFixUnreachableCode.ts +++ b/tests/cases/fourslash/codeFixUnreachableCode.ts @@ -2,7 +2,7 @@ ////function f() { //// return f(); -//// return 1; +//// [|return|] 1; //// function f() {} //// return 2; //// type T = number; @@ -10,11 +10,18 @@ //// const enum E {} //// enum E {} //// namespace N { export type T = number; } -//// namespace N { export const x = 0; } -//// var x; -//// var y = 0; +//// namespace N { export const x: T = 0; } +//// var x: I; +//// var y: T = 0; +//// E; N; x; y; ////} +verify.getSuggestionDiagnostics([{ + message: "Unreachable code detected.", + code: 7027, + reportsUnnecessary: true, +}]); + verify.codeFix({ description: "Remove unreachable code", index: 0, @@ -26,6 +33,6 @@ verify.codeFix({ interface I {} const enum E {} namespace N { export type T = number; } - var x; + var x: I; }`, }); diff --git a/tests/cases/fourslash/codeFixUnreachableCode_noSuggestionIfDisabled.ts b/tests/cases/fourslash/codeFixUnreachableCode_noSuggestionIfDisabled.ts new file mode 100644 index 0000000000000..35ad3c430a335 --- /dev/null +++ b/tests/cases/fourslash/codeFixUnreachableCode_noSuggestionIfDisabled.ts @@ -0,0 +1,7 @@ +/// + +// @allowUnreachableCode: true + +////if (false) 0; + +verify.getSuggestionDiagnostics([]); diff --git a/tests/cases/fourslash/codeFixUnusedIdentifier_suggestion.ts b/tests/cases/fourslash/codeFixUnusedIdentifier_suggestion.ts index de671de1e5db8..b830ccad74640 100644 --- a/tests/cases/fourslash/codeFixUnusedIdentifier_suggestion.ts +++ b/tests/cases/fourslash/codeFixUnusedIdentifier_suggestion.ts @@ -10,13 +10,13 @@ verify.getSuggestionDiagnostics([ message: "'p' is declared but its value is never read.", range: r0, code: 6133, - unused: true, + reportsUnnecessary: true, }, { message: "'x' is declared but its value is never read.", range: r1, code: 6133, - unused: true, + reportsUnnecessary: true, } ]); diff --git a/tests/cases/fourslash/codeFixUnusedLabel.ts b/tests/cases/fourslash/codeFixUnusedLabel.ts index 0feea173b0c2b..38265aa818e10 100644 --- a/tests/cases/fourslash/codeFixUnusedLabel.ts +++ b/tests/cases/fourslash/codeFixUnusedLabel.ts @@ -1,8 +1,12 @@ /// -// @noUnusedLocals: true +/////* a */[|label|]/* b */:/* c */while (1) {} -/////* a */label/* b */:/* c */while (1) {} +verify.getSuggestionDiagnostics([{ + message: "Unused label.", + code: 7028, + reportsUnnecessary: true, +}]); verify.codeFix({ description: "Remove unused label", diff --git a/tests/cases/fourslash/codeFixUnusedLabel_noSuggestionIfDisabled.ts b/tests/cases/fourslash/codeFixUnusedLabel_noSuggestionIfDisabled.ts new file mode 100644 index 0000000000000..a7e504d2f66dd --- /dev/null +++ b/tests/cases/fourslash/codeFixUnusedLabel_noSuggestionIfDisabled.ts @@ -0,0 +1,7 @@ +/// + +// @allowUnusedLabels: true + +////foo: while (true) {} + +verify.getSuggestionDiagnostics([]); diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index b8b06edca15a6..57eda1e09471e 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -516,7 +516,7 @@ declare namespace FourSlashInterface { /** @default `test.ranges()[0]` */ range?: Range; code: number; - unused?: true; + reportsUnnecessary?: true; } interface VerifyDocumentHighlightsOptions { filesToSearch?: ReadonlyArray; diff --git a/tests/cases/fourslash/suggestionOfUnusedVariableWithExternalModule.ts b/tests/cases/fourslash/suggestionOfUnusedVariableWithExternalModule.ts index b86f79a8e4914..77d0b6157fde5 100644 --- a/tests/cases/fourslash/suggestionOfUnusedVariableWithExternalModule.ts +++ b/tests/cases/fourslash/suggestionOfUnusedVariableWithExternalModule.ts @@ -3,15 +3,15 @@ //@allowJs: true // @Filename: /mymodule.js -////(function ([|root|], factory) { -//// module.exports = factory(); -////}(this, function () { -//// var [|unusedVar|] = "something"; -//// return {}; +////(function ([|root|], factory) { +//// module.exports = factory(); +////}(this, function () { +//// var [|unusedVar|] = "something"; +//// return {}; ////})); // @Filename: /app.js -//////@ts-check +//////@ts-check ////require("./mymodule"); const [range0, range1] = test.ranges(); @@ -20,12 +20,17 @@ goTo.file("/app.js"); verify.getSuggestionDiagnostics([]); goTo.file("/mymodule.js"); -verify.getSuggestionDiagnostics([{ - message: "'root' is declared but its value is never read.", - code: 6133, - range: range0 -}, { +verify.getSuggestionDiagnostics([ + { + message: "'root' is declared but its value is never read.", + code: 6133, + range: range0, + reportsUnnecessary: true, + }, + { message: "'unusedVar' is declared but its value is never read.", code: 6133, - range: range1 -}]); + range: range1, + reportsUnnecessary: true, + }, +]);