diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3e92b9eaad4..133065b4e88 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2240,7 +2240,7 @@ namespace ts { const namespaceMeaning = SymbolFlags.Namespace | (isInJSFile(name) ? meaning & SymbolFlags.Value : 0); let symbol: Symbol | undefined; if (name.kind === SyntaxKind.Identifier) { - const message = meaning === namespaceMeaning ? Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(getFirstIdentifier(name).escapedText); + const message = meaning === namespaceMeaning ? Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(getFirstIdentifier(name)); const symbolFromJSPrototype = isInJSFile(name) ? resolveEntityNameFromAssignmentDeclaration(name, meaning) : undefined; symbol = resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, /*isUse*/ true); if (!symbol) { @@ -15271,8 +15271,8 @@ namespace ts { // EXPRESSION TYPE CHECKING - function getCannotFindNameDiagnosticForName(name: __String): DiagnosticMessage { - switch (name) { + function getCannotFindNameDiagnosticForName(node: Identifier): DiagnosticMessage { + switch (node.escapedText) { case "document": case "console": return Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_include_dom; @@ -15303,7 +15303,13 @@ namespace ts { case "Iterator": case "AsyncIterator": return Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later; - default: return Diagnostics.Cannot_find_name_0; + default: + if (node.parent.kind === SyntaxKind.ShorthandPropertyAssignment) { + return Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer; + } + else { + return Diagnostics.Cannot_find_name_0; + } } } @@ -15315,7 +15321,7 @@ namespace ts { node, node.escapedText, SymbolFlags.Value | SymbolFlags.ExportValue, - getCannotFindNameDiagnosticForName(node.escapedText), + getCannotFindNameDiagnosticForName(node), node, !isWriteOnlyAccess(node), /*excludeGlobals*/ false, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 4c06a233eb7..cd08731be02 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -4950,5 +4950,9 @@ "Allow accessing UMD globals from modules.": { "category": "Message", "code": 95076 + }, + "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer." :{ + "category": "Error", + "code": 18004 } } diff --git a/tests/baselines/reference/checkDestructuringShorthandAssigment.errors.txt b/tests/baselines/reference/checkDestructuringShorthandAssigment.errors.txt index aca20286905..f6b8576c834 100644 --- a/tests/baselines/reference/checkDestructuringShorthandAssigment.errors.txt +++ b/tests/baselines/reference/checkDestructuringShorthandAssigment.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/bug25434.js(4,9): error TS2304: Cannot find name 'b'. +tests/cases/compiler/bug25434.js(4,9): error TS18004: No value exists in scope for the shorthand property 'b'. Either declare one or provide an initializer. ==== tests/cases/compiler/bug25434.js (1 errors) ==== @@ -7,5 +7,5 @@ tests/cases/compiler/bug25434.js(4,9): error TS2304: Cannot find name 'b'. Test(({ b = '5' } = {})); ~ -!!! error TS2304: Cannot find name 'b'. +!!! error TS18004: No value exists in scope for the shorthand property 'b'. Either declare one or provide an initializer. \ No newline at end of file diff --git a/tests/baselines/reference/incompleteObjectLiteral1.errors.txt b/tests/baselines/reference/incompleteObjectLiteral1.errors.txt index 9122063302e..453ba9da589 100644 --- a/tests/baselines/reference/incompleteObjectLiteral1.errors.txt +++ b/tests/baselines/reference/incompleteObjectLiteral1.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/incompleteObjectLiteral1.ts(1,12): error TS2304: Cannot find name 'aa'. +tests/cases/compiler/incompleteObjectLiteral1.ts(1,12): error TS18004: No value exists in scope for the shorthand property 'aa'. Either declare one or provide an initializer. tests/cases/compiler/incompleteObjectLiteral1.ts(1,14): error TS1005: ',' expected. ==== tests/cases/compiler/incompleteObjectLiteral1.ts (2 errors) ==== var tt = { aa; } ~~ -!!! error TS2304: Cannot find name 'aa'. +!!! error TS18004: No value exists in scope for the shorthand property 'aa'. Either declare one or provide an initializer. ~ !!! error TS1005: ',' expected. var x = tt; \ No newline at end of file diff --git a/tests/baselines/reference/objectLiteralShorthandPropertiesErrorFromNoneExistingIdentifier.errors.txt b/tests/baselines/reference/objectLiteralShorthandPropertiesErrorFromNoneExistingIdentifier.errors.txt index fcd04b27754..db52e0e0454 100644 --- a/tests/baselines/reference/objectLiteralShorthandPropertiesErrorFromNoneExistingIdentifier.errors.txt +++ b/tests/baselines/reference/objectLiteralShorthandPropertiesErrorFromNoneExistingIdentifier.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNoneExistingIdentifier.ts(3,5): error TS2304: Cannot find name 'undefinedVariable'. +tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNoneExistingIdentifier.ts(3,5): error TS18004: No value exists in scope for the shorthand property 'undefinedVariable'. Either declare one or provide an initializer. ==== tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNoneExistingIdentifier.ts (1 errors) ==== @@ -6,6 +6,6 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPr x, // OK undefinedVariable // Error ~~~~~~~~~~~~~~~~~ -!!! error TS2304: Cannot find name 'undefinedVariable'. +!!! error TS18004: No value exists in scope for the shorthand property 'undefinedVariable'. Either declare one or provide an initializer. } \ No newline at end of file diff --git a/tests/baselines/reference/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.errors.txt b/tests/baselines/reference/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.errors.txt index 17c7126ff33..04a0565174f 100644 --- a/tests/baselines/reference/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.errors.txt +++ b/tests/baselines/reference/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.errors.txt @@ -7,12 +7,12 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPr tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(9,8): error TS1005: ':' expected. tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(10,10): error TS1005: ':' expected. tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(12,1): error TS1005: ':' expected. -tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(15,5): error TS2304: Cannot find name 'a'. +tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(15,5): error TS18004: No value exists in scope for the shorthand property 'a'. Either declare one or provide an initializer. tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(15,6): error TS1005: ',' expected. -tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(16,5): error TS2304: Cannot find name 'a'. +tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(16,5): error TS18004: No value exists in scope for the shorthand property 'a'. Either declare one or provide an initializer. tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(16,6): error TS1005: ',' expected. tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(16,12): error TS1005: ':' expected. -tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(17,5): error TS2304: Cannot find name 'a'. +tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(17,5): error TS18004: No value exists in scope for the shorthand property 'a'. Either declare one or provide an initializer. tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(17,6): error TS1005: ',' expected. tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(17,9): error TS1005: ':' expected. tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(20,17): error TS1005: ':' expected. @@ -53,19 +53,19 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPr var x = { a.b, ~ -!!! error TS2304: Cannot find name 'a'. +!!! error TS18004: No value exists in scope for the shorthand property 'a'. Either declare one or provide an initializer. ~ !!! error TS1005: ',' expected. a["ss"], ~ -!!! error TS2304: Cannot find name 'a'. +!!! error TS18004: No value exists in scope for the shorthand property 'a'. Either declare one or provide an initializer. ~ !!! error TS1005: ',' expected. ~ !!! error TS1005: ':' expected. a[1], ~ -!!! error TS2304: Cannot find name 'a'. +!!! error TS18004: No value exists in scope for the shorthand property 'a'. Either declare one or provide an initializer. ~ !!! error TS1005: ',' expected. ~ diff --git a/tests/baselines/reference/objectLiteralWithSemicolons1.errors.txt b/tests/baselines/reference/objectLiteralWithSemicolons1.errors.txt index 43a0927cc29..6dc19e6ed53 100644 --- a/tests/baselines/reference/objectLiteralWithSemicolons1.errors.txt +++ b/tests/baselines/reference/objectLiteralWithSemicolons1.errors.txt @@ -1,19 +1,19 @@ -tests/cases/compiler/objectLiteralWithSemicolons1.ts(1,11): error TS2304: Cannot find name 'a'. +tests/cases/compiler/objectLiteralWithSemicolons1.ts(1,11): error TS18004: No value exists in scope for the shorthand property 'a'. Either declare one or provide an initializer. tests/cases/compiler/objectLiteralWithSemicolons1.ts(1,12): error TS1005: ',' expected. -tests/cases/compiler/objectLiteralWithSemicolons1.ts(1,14): error TS2304: Cannot find name 'b'. +tests/cases/compiler/objectLiteralWithSemicolons1.ts(1,14): error TS18004: No value exists in scope for the shorthand property 'b'. Either declare one or provide an initializer. tests/cases/compiler/objectLiteralWithSemicolons1.ts(1,15): error TS1005: ',' expected. -tests/cases/compiler/objectLiteralWithSemicolons1.ts(1,17): error TS2304: Cannot find name 'c'. +tests/cases/compiler/objectLiteralWithSemicolons1.ts(1,17): error TS18004: No value exists in scope for the shorthand property 'c'. Either declare one or provide an initializer. ==== tests/cases/compiler/objectLiteralWithSemicolons1.ts (5 errors) ==== var v = { a; b; c } ~ -!!! error TS2304: Cannot find name 'a'. +!!! error TS18004: No value exists in scope for the shorthand property 'a'. Either declare one or provide an initializer. ~ !!! error TS1005: ',' expected. ~ -!!! error TS2304: Cannot find name 'b'. +!!! error TS18004: No value exists in scope for the shorthand property 'b'. Either declare one or provide an initializer. ~ !!! error TS1005: ',' expected. ~ -!!! error TS2304: Cannot find name 'c'. \ No newline at end of file +!!! error TS18004: No value exists in scope for the shorthand property 'c'. Either declare one or provide an initializer. \ No newline at end of file diff --git a/tests/baselines/reference/objectLiteralWithSemicolons2.errors.txt b/tests/baselines/reference/objectLiteralWithSemicolons2.errors.txt index 6fc0b5ff139..88280933a65 100644 --- a/tests/baselines/reference/objectLiteralWithSemicolons2.errors.txt +++ b/tests/baselines/reference/objectLiteralWithSemicolons2.errors.txt @@ -1,23 +1,23 @@ -tests/cases/compiler/objectLiteralWithSemicolons2.ts(2,3): error TS2304: Cannot find name 'a'. +tests/cases/compiler/objectLiteralWithSemicolons2.ts(2,3): error TS18004: No value exists in scope for the shorthand property 'a'. Either declare one or provide an initializer. tests/cases/compiler/objectLiteralWithSemicolons2.ts(2,4): error TS1005: ',' expected. -tests/cases/compiler/objectLiteralWithSemicolons2.ts(3,3): error TS2304: Cannot find name 'b'. +tests/cases/compiler/objectLiteralWithSemicolons2.ts(3,3): error TS18004: No value exists in scope for the shorthand property 'b'. Either declare one or provide an initializer. tests/cases/compiler/objectLiteralWithSemicolons2.ts(3,4): error TS1005: ',' expected. -tests/cases/compiler/objectLiteralWithSemicolons2.ts(4,3): error TS2304: Cannot find name 'c'. +tests/cases/compiler/objectLiteralWithSemicolons2.ts(4,3): error TS18004: No value exists in scope for the shorthand property 'c'. Either declare one or provide an initializer. ==== tests/cases/compiler/objectLiteralWithSemicolons2.ts (5 errors) ==== var v = { a; ~ -!!! error TS2304: Cannot find name 'a'. +!!! error TS18004: No value exists in scope for the shorthand property 'a'. Either declare one or provide an initializer. ~ !!! error TS1005: ',' expected. b; ~ -!!! error TS2304: Cannot find name 'b'. +!!! error TS18004: No value exists in scope for the shorthand property 'b'. Either declare one or provide an initializer. ~ !!! error TS1005: ',' expected. c ~ -!!! error TS2304: Cannot find name 'c'. +!!! error TS18004: No value exists in scope for the shorthand property 'c'. Either declare one or provide an initializer. } \ No newline at end of file diff --git a/tests/baselines/reference/objectLiteralWithSemicolons3.errors.txt b/tests/baselines/reference/objectLiteralWithSemicolons3.errors.txt index dd5709b9822..14380be93c4 100644 --- a/tests/baselines/reference/objectLiteralWithSemicolons3.errors.txt +++ b/tests/baselines/reference/objectLiteralWithSemicolons3.errors.txt @@ -1,8 +1,8 @@ -tests/cases/compiler/objectLiteralWithSemicolons3.ts(2,3): error TS2304: Cannot find name 'a'. +tests/cases/compiler/objectLiteralWithSemicolons3.ts(2,3): error TS18004: No value exists in scope for the shorthand property 'a'. Either declare one or provide an initializer. tests/cases/compiler/objectLiteralWithSemicolons3.ts(2,4): error TS1005: ',' expected. -tests/cases/compiler/objectLiteralWithSemicolons3.ts(3,3): error TS2304: Cannot find name 'b'. +tests/cases/compiler/objectLiteralWithSemicolons3.ts(3,3): error TS18004: No value exists in scope for the shorthand property 'b'. Either declare one or provide an initializer. tests/cases/compiler/objectLiteralWithSemicolons3.ts(3,4): error TS1005: ',' expected. -tests/cases/compiler/objectLiteralWithSemicolons3.ts(4,3): error TS2304: Cannot find name 'c'. +tests/cases/compiler/objectLiteralWithSemicolons3.ts(4,3): error TS18004: No value exists in scope for the shorthand property 'c'. Either declare one or provide an initializer. tests/cases/compiler/objectLiteralWithSemicolons3.ts(4,4): error TS1005: ',' expected. @@ -10,17 +10,17 @@ tests/cases/compiler/objectLiteralWithSemicolons3.ts(4,4): error TS1005: ',' exp var v = { a; ~ -!!! error TS2304: Cannot find name 'a'. +!!! error TS18004: No value exists in scope for the shorthand property 'a'. Either declare one or provide an initializer. ~ !!! error TS1005: ',' expected. b; ~ -!!! error TS2304: Cannot find name 'b'. +!!! error TS18004: No value exists in scope for the shorthand property 'b'. Either declare one or provide an initializer. ~ !!! error TS1005: ',' expected. c; ~ -!!! error TS2304: Cannot find name 'c'. +!!! error TS18004: No value exists in scope for the shorthand property 'c'. Either declare one or provide an initializer. ~ !!! error TS1005: ',' expected. } \ No newline at end of file diff --git a/tests/baselines/reference/objectLiteralWithSemicolons4.errors.txt b/tests/baselines/reference/objectLiteralWithSemicolons4.errors.txt index e0ea42bb8c1..544bddafff2 100644 --- a/tests/baselines/reference/objectLiteralWithSemicolons4.errors.txt +++ b/tests/baselines/reference/objectLiteralWithSemicolons4.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/objectLiteralWithSemicolons4.ts(2,3): error TS2304: Cannot find name 'a'. +tests/cases/compiler/objectLiteralWithSemicolons4.ts(2,3): error TS18004: No value exists in scope for the shorthand property 'a'. Either declare one or provide an initializer. tests/cases/compiler/objectLiteralWithSemicolons4.ts(3,1): error TS1005: ',' expected. @@ -6,7 +6,7 @@ tests/cases/compiler/objectLiteralWithSemicolons4.ts(3,1): error TS1005: ',' exp var v = { a ~ -!!! error TS2304: Cannot find name 'a'. +!!! error TS18004: No value exists in scope for the shorthand property 'a'. Either declare one or provide an initializer. ; ~ !!! error TS1005: ',' expected. \ No newline at end of file diff --git a/tests/baselines/reference/parser512097.errors.txt b/tests/baselines/reference/parser512097.errors.txt index 5a25284ba51..7363372c331 100644 --- a/tests/baselines/reference/parser512097.errors.txt +++ b/tests/baselines/reference/parser512097.errors.txt @@ -1,11 +1,11 @@ -tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512097.ts(1,12): error TS2304: Cannot find name 'aa'. +tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512097.ts(1,12): error TS18004: No value exists in scope for the shorthand property 'aa'. Either declare one or provide an initializer. tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512097.ts(1,14): error TS1005: ',' expected. ==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512097.ts (2 errors) ==== var tt = { aa; } ~~ -!!! error TS2304: Cannot find name 'aa'. +!!! error TS18004: No value exists in scope for the shorthand property 'aa'. Either declare one or provide an initializer. ~ !!! error TS1005: ',' expected. diff --git a/tests/baselines/reference/parserErrorRecovery_ObjectLiteral2.errors.txt b/tests/baselines/reference/parserErrorRecovery_ObjectLiteral2.errors.txt index 8be4448ae52..05c6ba6c8d6 100644 --- a/tests/baselines/reference/parserErrorRecovery_ObjectLiteral2.errors.txt +++ b/tests/baselines/reference/parserErrorRecovery_ObjectLiteral2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ObjectLiterals/parserErrorRecovery_ObjectLiteral2.ts(1,11): error TS2304: Cannot find name 'a'. +tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ObjectLiterals/parserErrorRecovery_ObjectLiteral2.ts(1,11): error TS18004: No value exists in scope for the shorthand property 'a'. Either declare one or provide an initializer. tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ObjectLiterals/parserErrorRecovery_ObjectLiteral2.ts(2,1): error TS1005: ',' expected. tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ObjectLiterals/parserErrorRecovery_ObjectLiteral2.ts(2,7): error TS1005: ':' expected. tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ObjectLiterals/parserErrorRecovery_ObjectLiteral2.ts(2,8): error TS1005: '}' expected. @@ -7,7 +7,7 @@ tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ObjectLiterals/parserEr ==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ObjectLiterals/parserErrorRecovery_ObjectLiteral2.ts (4 errors) ==== var v = { a ~ -!!! error TS2304: Cannot find name 'a'. +!!! error TS18004: No value exists in scope for the shorthand property 'a'. Either declare one or provide an initializer. return; ~~~~~~ !!! error TS1005: ',' expected. diff --git a/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring.errors.txt b/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring.errors.txt index 7d2ebd38c35..c22071d4b75 100644 --- a/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring.errors.txt +++ b/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring.errors.txt @@ -13,7 +13,7 @@ tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(85,19): erro Types of property 'x' are incompatible. Type 'number' is not assignable to type 'string'. tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(85,26): error TS2322: Type 'number' is not assignable to type 'string'. -tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(111,12): error TS2304: Cannot find name 's'. +tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(111,12): error TS18004: No value exists in scope for the shorthand property 's'. Either declare one or provide an initializer. tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(111,14): error TS1312: '=' can only be used in an object literal property inside a destructuring assignment. @@ -160,7 +160,7 @@ tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(111,14): err (function() { let a = { s = 5 }; ~ -!!! error TS2304: Cannot find name 's'. +!!! error TS18004: No value exists in scope for the shorthand property 's'. Either declare one or provide an initializer. ~ !!! error TS1312: '=' can only be used in an object literal property inside a destructuring assignment. }); diff --git a/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring_ES6.errors.txt b/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring_ES6.errors.txt index fa821aa51b6..48ce3922c47 100644 --- a/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring_ES6.errors.txt +++ b/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring_ES6.errors.txt @@ -13,7 +13,7 @@ tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(85,19): Types of property 'x' are incompatible. Type 'number' is not assignable to type 'string'. tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(85,26): error TS2322: Type 'number' is not assignable to type 'string'. -tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(111,12): error TS2304: Cannot find name 's'. +tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(111,12): error TS18004: No value exists in scope for the shorthand property 's'. Either declare one or provide an initializer. tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(111,14): error TS1312: '=' can only be used in an object literal property inside a destructuring assignment. @@ -160,7 +160,7 @@ tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(111,14): (function() { let a = { s = 5 }; ~ -!!! error TS2304: Cannot find name 's'. +!!! error TS18004: No value exists in scope for the shorthand property 's'. Either declare one or provide an initializer. ~ !!! error TS1312: '=' can only be used in an object literal property inside a destructuring assignment. }); diff --git a/tests/baselines/reference/shorthandPropertyUndefined.errors.txt b/tests/baselines/reference/shorthandPropertyUndefined.errors.txt new file mode 100644 index 00000000000..da6f9ad5984 --- /dev/null +++ b/tests/baselines/reference/shorthandPropertyUndefined.errors.txt @@ -0,0 +1,7 @@ +tests/cases/compiler/shorthandPropertyUndefined.ts(1,11): error TS18004: No value exists in scope for the shorthand property 'b'. Either declare one or provide an initializer. + + +==== tests/cases/compiler/shorthandPropertyUndefined.ts (1 errors) ==== + var a = { b }; + ~ +!!! error TS18004: No value exists in scope for the shorthand property 'b'. Either declare one or provide an initializer. \ No newline at end of file diff --git a/tests/baselines/reference/shorthandPropertyUndefined.js b/tests/baselines/reference/shorthandPropertyUndefined.js new file mode 100644 index 00000000000..643b75bb054 --- /dev/null +++ b/tests/baselines/reference/shorthandPropertyUndefined.js @@ -0,0 +1,5 @@ +//// [shorthandPropertyUndefined.ts] +var a = { b }; + +//// [shorthandPropertyUndefined.js] +var a = { b: b }; diff --git a/tests/baselines/reference/shorthandPropertyUndefined.symbols b/tests/baselines/reference/shorthandPropertyUndefined.symbols new file mode 100644 index 00000000000..fd7c0fe4c23 --- /dev/null +++ b/tests/baselines/reference/shorthandPropertyUndefined.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/shorthandPropertyUndefined.ts === +var a = { b }; +>a : Symbol(a, Decl(shorthandPropertyUndefined.ts, 0, 3)) +>b : Symbol(b, Decl(shorthandPropertyUndefined.ts, 0, 9)) + diff --git a/tests/baselines/reference/shorthandPropertyUndefined.types b/tests/baselines/reference/shorthandPropertyUndefined.types new file mode 100644 index 00000000000..7ed8983dc3c --- /dev/null +++ b/tests/baselines/reference/shorthandPropertyUndefined.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/shorthandPropertyUndefined.ts === +var a = { b }; +>a : { b: any; } +>{ b } : { b: any; } +>b : any + diff --git a/tests/cases/compiler/shorthandPropertyUndefined.ts b/tests/cases/compiler/shorthandPropertyUndefined.ts new file mode 100644 index 00000000000..0b9ac3fcbef --- /dev/null +++ b/tests/cases/compiler/shorthandPropertyUndefined.ts @@ -0,0 +1 @@ +var a = { b }; \ No newline at end of file