mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-12 21:37:41 -06:00
commit
da312398f5
@ -16616,12 +16616,18 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
}
|
||||
const suggestion = getSuggestionForNonexistentProperty(propNode, containingType);
|
||||
if (suggestion !== undefined) {
|
||||
errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, declarationNameToString(propNode), typeToString(containingType), suggestion);
|
||||
const promisedType = getPromisedTypeOfPromise(containingType);
|
||||
if (promisedType && getPropertyOfType(promisedType, propNode.escapedText)) {
|
||||
errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_forget_to_use_await, declarationNameToString(propNode), typeToString(containingType));
|
||||
}
|
||||
else {
|
||||
errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Property_0_does_not_exist_on_type_1, declarationNameToString(propNode), typeToString(containingType));
|
||||
const suggestion = getSuggestionForNonexistentProperty(propNode, containingType);
|
||||
if (suggestion !== undefined) {
|
||||
errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, declarationNameToString(propNode), typeToString(containingType), suggestion);
|
||||
}
|
||||
else {
|
||||
errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Property_0_does_not_exist_on_type_1, declarationNameToString(propNode), typeToString(containingType));
|
||||
}
|
||||
}
|
||||
diagnostics.add(createDiagnosticForNodeFromMessageChain(propNode, errorInfo));
|
||||
}
|
||||
|
||||
@ -2012,7 +2012,10 @@
|
||||
"category": "Error",
|
||||
"code": 2569
|
||||
},
|
||||
|
||||
"Property '{0}' does not exist on type '{1}'. Did you forget to use 'await'?": {
|
||||
"category": "Error",
|
||||
"code": 2570
|
||||
},
|
||||
"JSX element attributes type '{0}' may not be a union type.": {
|
||||
"category": "Error",
|
||||
"code": 2600
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
tests/cases/compiler/nonexistentPropertyAvailableOnPromisedType.ts(2,7): error TS2570: Property 'toLowerCase' does not exist on type 'Promise<string>'. Did you forget to use 'await'?
|
||||
|
||||
|
||||
==== tests/cases/compiler/nonexistentPropertyAvailableOnPromisedType.ts (1 errors) ====
|
||||
function f(x: Promise<string>) {
|
||||
x.toLowerCase();
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2570: Property 'toLowerCase' does not exist on type 'Promise<string>'. Did you forget to use 'await'?
|
||||
}
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
//// [nonexistentPropertyAvailableOnPromisedType.ts]
|
||||
function f(x: Promise<string>) {
|
||||
x.toLowerCase();
|
||||
}
|
||||
|
||||
|
||||
//// [nonexistentPropertyAvailableOnPromisedType.js]
|
||||
function f(x) {
|
||||
x.toLowerCase();
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
=== tests/cases/compiler/nonexistentPropertyAvailableOnPromisedType.ts ===
|
||||
function f(x: Promise<string>) {
|
||||
>f : Symbol(f, Decl(nonexistentPropertyAvailableOnPromisedType.ts, 0, 0))
|
||||
>x : Symbol(x, Decl(nonexistentPropertyAvailableOnPromisedType.ts, 0, 11))
|
||||
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --))
|
||||
|
||||
x.toLowerCase();
|
||||
>x : Symbol(x, Decl(nonexistentPropertyAvailableOnPromisedType.ts, 0, 11))
|
||||
}
|
||||
|
||||
@ -0,0 +1,13 @@
|
||||
=== tests/cases/compiler/nonexistentPropertyAvailableOnPromisedType.ts ===
|
||||
function f(x: Promise<string>) {
|
||||
>f : (x: Promise<string>) => void
|
||||
>x : Promise<string>
|
||||
>Promise : Promise<T>
|
||||
|
||||
x.toLowerCase();
|
||||
>x.toLowerCase() : any
|
||||
>x.toLowerCase : any
|
||||
>x : Promise<string>
|
||||
>toLowerCase : any
|
||||
}
|
||||
|
||||
@ -0,0 +1,12 @@
|
||||
tests/cases/compiler/nonexistentPropertyOnUnion.ts(2,7): error TS2339: Property 'toLowerCase' does not exist on type 'string | Promise<string>'.
|
||||
Property 'toLowerCase' does not exist on type 'Promise<string>'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/nonexistentPropertyOnUnion.ts (1 errors) ====
|
||||
function f(x: string | Promise<string>) {
|
||||
x.toLowerCase();
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2339: Property 'toLowerCase' does not exist on type 'string | Promise<string>'.
|
||||
!!! error TS2339: Property 'toLowerCase' does not exist on type 'Promise<string>'.
|
||||
}
|
||||
|
||||
10
tests/baselines/reference/nonexistentPropertyOnUnion.js
Normal file
10
tests/baselines/reference/nonexistentPropertyOnUnion.js
Normal file
@ -0,0 +1,10 @@
|
||||
//// [nonexistentPropertyOnUnion.ts]
|
||||
function f(x: string | Promise<string>) {
|
||||
x.toLowerCase();
|
||||
}
|
||||
|
||||
|
||||
//// [nonexistentPropertyOnUnion.js]
|
||||
function f(x) {
|
||||
x.toLowerCase();
|
||||
}
|
||||
10
tests/baselines/reference/nonexistentPropertyOnUnion.symbols
Normal file
10
tests/baselines/reference/nonexistentPropertyOnUnion.symbols
Normal file
@ -0,0 +1,10 @@
|
||||
=== tests/cases/compiler/nonexistentPropertyOnUnion.ts ===
|
||||
function f(x: string | Promise<string>) {
|
||||
>f : Symbol(f, Decl(nonexistentPropertyOnUnion.ts, 0, 0))
|
||||
>x : Symbol(x, Decl(nonexistentPropertyOnUnion.ts, 0, 11))
|
||||
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --))
|
||||
|
||||
x.toLowerCase();
|
||||
>x : Symbol(x, Decl(nonexistentPropertyOnUnion.ts, 0, 11))
|
||||
}
|
||||
|
||||
13
tests/baselines/reference/nonexistentPropertyOnUnion.types
Normal file
13
tests/baselines/reference/nonexistentPropertyOnUnion.types
Normal file
@ -0,0 +1,13 @@
|
||||
=== tests/cases/compiler/nonexistentPropertyOnUnion.ts ===
|
||||
function f(x: string | Promise<string>) {
|
||||
>f : (x: string | Promise<string>) => void
|
||||
>x : string | Promise<string>
|
||||
>Promise : Promise<T>
|
||||
|
||||
x.toLowerCase();
|
||||
>x.toLowerCase() : any
|
||||
>x.toLowerCase : any
|
||||
>x : string | Promise<string>
|
||||
>toLowerCase : any
|
||||
}
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
tests/cases/compiler/nonexistentPropertyUnavailableOnPromisedType.ts(2,7): error TS2339: Property 'toLowerCase' does not exist on type 'Promise<number>'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/nonexistentPropertyUnavailableOnPromisedType.ts (1 errors) ====
|
||||
function f(x: Promise<number>) {
|
||||
x.toLowerCase();
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2339: Property 'toLowerCase' does not exist on type 'Promise<number>'.
|
||||
}
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
//// [nonexistentPropertyUnavailableOnPromisedType.ts]
|
||||
function f(x: Promise<number>) {
|
||||
x.toLowerCase();
|
||||
}
|
||||
|
||||
|
||||
//// [nonexistentPropertyUnavailableOnPromisedType.js]
|
||||
function f(x) {
|
||||
x.toLowerCase();
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
=== tests/cases/compiler/nonexistentPropertyUnavailableOnPromisedType.ts ===
|
||||
function f(x: Promise<number>) {
|
||||
>f : Symbol(f, Decl(nonexistentPropertyUnavailableOnPromisedType.ts, 0, 0))
|
||||
>x : Symbol(x, Decl(nonexistentPropertyUnavailableOnPromisedType.ts, 0, 11))
|
||||
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --))
|
||||
|
||||
x.toLowerCase();
|
||||
>x : Symbol(x, Decl(nonexistentPropertyUnavailableOnPromisedType.ts, 0, 11))
|
||||
}
|
||||
|
||||
@ -0,0 +1,13 @@
|
||||
=== tests/cases/compiler/nonexistentPropertyUnavailableOnPromisedType.ts ===
|
||||
function f(x: Promise<number>) {
|
||||
>f : (x: Promise<number>) => void
|
||||
>x : Promise<number>
|
||||
>Promise : Promise<T>
|
||||
|
||||
x.toLowerCase();
|
||||
>x.toLowerCase() : any
|
||||
>x.toLowerCase : any
|
||||
>x : Promise<number>
|
||||
>toLowerCase : any
|
||||
}
|
||||
|
||||
@ -0,0 +1,3 @@
|
||||
function f(x: Promise<string>) {
|
||||
x.toLowerCase();
|
||||
}
|
||||
3
tests/cases/compiler/nonexistentPropertyOnUnion.ts
Normal file
3
tests/cases/compiler/nonexistentPropertyOnUnion.ts
Normal file
@ -0,0 +1,3 @@
|
||||
function f(x: string | Promise<string>) {
|
||||
x.toLowerCase();
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
function f(x: Promise<number>) {
|
||||
x.toLowerCase();
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user