mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-03-15 05:55:11 -05:00
diagnostic messages conflicts resolved
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
5
tests/baselines/reference/shorthandPropertyUndefined.js
Normal file
5
tests/baselines/reference/shorthandPropertyUndefined.js
Normal file
@@ -0,0 +1,5 @@
|
||||
//// [shorthandPropertyUndefined.ts]
|
||||
var a = { b };
|
||||
|
||||
//// [shorthandPropertyUndefined.js]
|
||||
var a = { b: b };
|
||||
@@ -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))
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
=== tests/cases/compiler/shorthandPropertyUndefined.ts ===
|
||||
var a = { b };
|
||||
>a : { b: any; }
|
||||
>{ b } : { b: any; }
|
||||
>b : any
|
||||
|
||||
1
tests/cases/compiler/shorthandPropertyUndefined.ts
Normal file
1
tests/cases/compiler/shorthandPropertyUndefined.ts
Normal file
@@ -0,0 +1 @@
|
||||
var a = { b };
|
||||
Reference in New Issue
Block a user