Address PR comments

This commit is contained in:
Nathan Shively-Sanders
2019-07-01 15:06:16 -07:00
parent 19061420af
commit f139455229
11 changed files with 58 additions and 41 deletions
+4 -4
View File
@@ -21693,10 +21693,10 @@ namespace ts {
i++;
}
const related = map(
max > 1 ? allDiagnostics[minIndex] : flatten(allDiagnostics),
d => typeof d.messageText === "string" ? (d as DiagnosticMessageChain) : d.messageText);
diagnostics.add(createDiagnosticForNodeFromMessageChain(node, chainDiagnosticMessages(related, Diagnostics.No_overload_matches_this_call)));
const diags = max > 1 ? allDiagnostics[minIndex] : flatten(allDiagnostics);
const chain = map(diags, d => typeof d.messageText === "string" ? (d as DiagnosticMessageChain) : d.messageText);
const related = flatMap(diags, d => (d as Diagnostic).relatedInformation) as DiagnosticRelatedInformation[];
diagnostics.add(createDiagnosticForNodeFromMessageChain(node, chainDiagnosticMessages(chain, Diagnostics.No_overload_matches_this_call), related));
}
}
else if (candidateForArgumentArityError) {
+8 -35
View File
@@ -7170,36 +7170,6 @@ namespace ts {
return d1.relatedInformation ? Comparison.LessThan : Comparison.GreaterThan;
}
// function compareMessageText(t1: string | DiagnosticMessageChain[], t2: string | DiagnosticMessageChain[]): Comparison {
// if (typeof t1 === 'string' && typeof t2 === 'string') {
// return compareStringsCaseSensitive(t1, t2)
// }
// else if (Array.isArray(t1) && Array.isArray(t2)) {
// if (t1.length < t2.length) {
// return Comparison.LessThan;
// }
// else if (t1.length > t2.length) {
// return Comparison.GreaterThan;
// }
// else {
// for (let i = 0; i < t1.length; i++) {
// t1[i].messageText
// const res = cmps(t1[i], t2[i]);
// if (res) {
// return res;
// }
// }
// return Comparison.EqualTo;
// }
// }
// else if (typeof t1 === 'string') {
// return Comparison.LessThan;
// }
// else {
// return Comparison.GreaterThan;
// }
// }
function compareMessageText(t1: string | DiagnosticMessageChain, t2: string | DiagnosticMessageChain): Comparison {
if (typeof t1 === "string" && typeof t2 === "string") {
return compareStringsCaseSensitive(t1, t2);
@@ -7223,16 +7193,19 @@ namespace ts {
if (!t2.next) {
return Comparison.GreaterThan;
}
res = compareValues(t1.next.length, t2.next.length);
if (res) {
return res;
}
for (let i = 0; i < t1.next.length; i++) {
const len = Math.min(t1.next.length, t2.next.length);
for (let i = 0; i < len; i++) {
res = compareMessageText(t1.next[i], t2.next[i]);
if (res) {
return res;
}
}
if (t1.next.length < t2.next.length) {
return Comparison.LessThan;
}
else if (t1.next.length > t2.next.length) {
return Comparison.GreaterThan;
}
return Comparison.EqualTo;
}
@@ -16,4 +16,6 @@ tests/cases/compiler/functionOverloads40.ts(4,9): error TS2763: No overload matc
!!! error TS2763: Type 'string' is not assignable to type 'number'.
!!! error TS2763: Overload 2 of 2, '(bar: { a: boolean; }[]): number', gave the following error.
!!! error TS2763: Type 'string' is not assignable to type 'boolean'.
!!! related TS6500 tests/cases/compiler/functionOverloads40.ts:1:19: The expected type comes from property 'a' which is declared here on type '{ a: number; }'
!!! related TS6500 tests/cases/compiler/functionOverloads40.ts:2:19: The expected type comes from property 'a' which is declared here on type '{ a: boolean; }'
@@ -16,4 +16,6 @@ tests/cases/compiler/functionOverloads41.ts(4,9): error TS2763: No overload matc
!!! error TS2763: Property 'a' is missing in type '{}' but required in type '{ a: number; }'.
!!! error TS2763: Overload 2 of 2, '(bar: { a: boolean; }[]): number', gave the following error.
!!! error TS2763: Property 'a' is missing in type '{}' but required in type '{ a: boolean; }'.
!!! related TS2728 tests/cases/compiler/functionOverloads41.ts:1:19: 'a' is declared here.
!!! related TS2728 tests/cases/compiler/functionOverloads41.ts:2:19: 'a' is declared here.
@@ -29,6 +29,8 @@ tests/cases/compiler/overloadResolutionTest1.ts(24,9): error TS2763: No overload
!!! error TS2763: Type 'string' is not assignable to type 'number'.
!!! error TS2763: Overload 2 of 2, '(bar: { a: boolean; }[]): number', gave the following error.
!!! error TS2763: Type 'string' is not assignable to type 'boolean'.
!!! related TS6500 tests/cases/compiler/overloadResolutionTest1.ts:1:19: The expected type comes from property 'a' which is declared here on type '{ a: number; }'
!!! related TS6500 tests/cases/compiler/overloadResolutionTest1.ts:2:19: The expected type comes from property 'a' which is declared here on type '{ a: boolean; }'
var x1111 = foo([{a:null}]); // works - ambiguous call is resolved to be the first in the overload set so this returns a string
@@ -46,6 +48,8 @@ tests/cases/compiler/overloadResolutionTest1.ts(24,9): error TS2763: No overload
!!! error TS2763: Type 'string' is not assignable to type 'number'.
!!! error TS2763: Overload 2 of 2, '(bar: { a: boolean; }): number', gave the following error.
!!! error TS2763: Type 'string' is not assignable to type 'boolean'.
!!! related TS6500 tests/cases/compiler/overloadResolutionTest1.ts:12:20: The expected type comes from property 'a' which is declared here on type '{ a: number; }'
!!! related TS6500 tests/cases/compiler/overloadResolutionTest1.ts:13:20: The expected type comes from property 'a' which is declared here on type '{ a: boolean; }'
function foo4(bar:{a:number;}):number;
@@ -57,4 +61,6 @@ tests/cases/compiler/overloadResolutionTest1.ts(24,9): error TS2763: No overload
!!! error TS2763: Overload 1 of 2, '(bar: { a: number; }): number', gave the following error.
!!! error TS2763: Type 'true' is not assignable to type 'number'.
!!! error TS2763: Overload 2 of 2, '(bar: { a: string; }): string', gave the following error.
!!! error TS2763: Type 'true' is not assignable to type 'string'.
!!! error TS2763: Type 'true' is not assignable to type 'string'.
!!! related TS6500 tests/cases/compiler/overloadResolutionTest1.ts:21:20: The expected type comes from property 'a' which is declared here on type '{ a: number; }'
!!! related TS6500 tests/cases/compiler/overloadResolutionTest1.ts:22:20: The expected type comes from property 'a' which is declared here on type '{ a: string; }'
@@ -68,4 +68,6 @@ tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts(19,14):
!!! error TS2763: Argument of type '(x: D) => G<D>' is not assignable to parameter of type '(x: B) => any'.
!!! error TS2763: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2763: Property 'q' is missing in type 'B' but required in type 'D'.
!!! related TS2728 tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts:4:15: 'q' is declared here.
!!! related TS2728 tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts:4:15: 'q' is declared here.
@@ -25,6 +25,7 @@ tests/cases/compiler/overloadsWithProvisionalErrors.ts(8,17): error TS2304: Cann
!!! error TS2763: Argument of type '(s: string) => {}' is not assignable to parameter of type 'string'.
!!! error TS2763: Overload 2 of 2, '(lambda: (s: string) => { a: number; b: number; }): string', gave the following error.
!!! error TS2763: Type '{}' is missing the following properties from type '{ a: number; b: number; }': a, b
!!! related TS6502 tests/cases/compiler/overloadsWithProvisionalErrors.ts:3:14: The expected type comes from the return type of this signature.
func(s => ({ a: blah, b: 3 })); // Only error inside the function, but not outside (since it would be applicable if not for the provisional error)
~~~~
!!! error TS2304: Cannot find name 'blah'.
@@ -35,5 +36,7 @@ tests/cases/compiler/overloadsWithProvisionalErrors.ts(8,17): error TS2304: Cann
!!! error TS2763: Argument of type '(s: string) => { a: any; }' is not assignable to parameter of type 'string'.
!!! error TS2763: Overload 2 of 2, '(lambda: (s: string) => { a: number; b: number; }): string', gave the following error.
!!! error TS2763: Property 'b' is missing in type '{ a: any; }' but required in type '{ a: number; b: number; }'.
!!! related TS2728 tests/cases/compiler/overloadsWithProvisionalErrors.ts:3:42: 'b' is declared here.
!!! related TS6502 tests/cases/compiler/overloadsWithProvisionalErrors.ts:3:14: The expected type comes from the return type of this signature.
~~~~
!!! error TS2304: Cannot find name 'blah'.
@@ -34,4 +34,7 @@ tests/cases/compiler/promiseTypeInference.ts(10,11): error TS2763: No overload m
!!! error TS2763: Types of parameters 'success' and 'onfulfilled' are incompatible.
!!! error TS2763: Type 'TResult1 | PromiseLike<TResult1>' is not assignable to type 'IPromise<TResult1 | TResult2>'.
!!! error TS2763: Type 'TResult1' is not assignable to type 'IPromise<TResult1 | TResult2>'.
!!! related TS2728 /.ts/lib.es5.d.ts:1413:5: 'catch' is declared here.
!!! related TS6502 tests/cases/compiler/promiseTypeInference.ts:2:23: The expected type comes from the return type of this signature.
!!! related TS6502 /.ts/lib.es5.d.ts:1406:57: The expected type comes from the return type of this signature.
@@ -105,6 +105,7 @@ tests/cases/conformance/jsx/file.tsx(36,12): error TS2763: No overload matches t
!!! error TS2763: Property 'yy' does not exist on type 'IntrinsicAttributes'.
!!! error TS2763: Overload 2 of 2, '(l: { yy: number; yy1: string; }): Element', gave the following error.
!!! error TS2763: Property 'yy1' is missing in type '{ yy: number; }' but required in type '{ yy: number; yy1: string; }'.
!!! related TS2728 tests/cases/conformance/jsx/file.tsx:3:43: 'yy1' is declared here.
const c2 = <OneThing {...obj} yy1 />; // type incompatible;
~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2763: No overload matches this call.
@@ -113,6 +114,7 @@ tests/cases/conformance/jsx/file.tsx(36,12): error TS2763: No overload matches t
!!! error TS2763: Property 'yy1' does not exist on type 'IntrinsicAttributes'.
!!! error TS2763: Overload 2 of 2, '(l: { yy: number; yy1: string; }): Element', gave the following error.
!!! error TS2763: Type 'true' is not assignable to type 'string'.
!!! related TS6500 tests/cases/conformance/jsx/file.tsx:3:43: The expected type comes from property 'yy1' which is declared here on type 'IntrinsicAttributes & { yy: number; yy1: string; }'
const c3 = <OneThing {...obj} {...{extra: "extra attr"}} />; // This is OK becuase all attribute are spread
const c4 = <OneThing {...obj} y1={10000} />; // extra property;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -146,6 +148,8 @@ tests/cases/conformance/jsx/file.tsx(36,12): error TS2763: No overload matches t
!!! error TS2763: Type 'true' is not assignable to type 'string'.
!!! error TS2763: Overload 2 of 2, '(n: { yy: string; direction?: number; }): Element', gave the following error.
!!! error TS2763: Property 'yy' is missing in type '{ extra-data: true; }' but required in type '{ yy: string; direction?: number; }'.
!!! related TS6500 tests/cases/conformance/jsx/file.tsx:21:38: The expected type comes from property 'extra-data' which is declared here on type 'IntrinsicAttributes & { "extra-data": string; }'
!!! related TS2728 tests/cases/conformance/jsx/file.tsx:22:38: 'yy' is declared here.
const d2 = <TestingOneThing yy="hello" direction="left" />
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2763: No overload matches this call.
@@ -154,6 +158,7 @@ tests/cases/conformance/jsx/file.tsx(36,12): error TS2763: No overload matches t
!!! error TS2763: Property 'yy' does not exist on type 'IntrinsicAttributes & { "extra-data": string; }'.
!!! error TS2763: Overload 2 of 2, '(n: { yy: string; direction?: number; }): Element', gave the following error.
!!! error TS2763: Type 'string' is not assignable to type 'number'.
!!! related TS6500 tests/cases/conformance/jsx/file.tsx:22:50: The expected type comes from property 'direction' which is declared here on type 'IntrinsicAttributes & { yy: string; direction?: number; }'
declare function TestingOptional(a: {y1?: string, y2?: number}): JSX.Element;
declare function TestingOptional(a: {y1?: string, y2?: number, children: JSX.Element}): JSX.Element;
@@ -169,6 +174,9 @@ tests/cases/conformance/jsx/file.tsx(36,12): error TS2763: No overload matches t
!!! error TS2763: Type 'true' is not assignable to type 'string'.
!!! error TS2763: Overload 3 of 3, '(a: { y1: boolean; y2?: number; y3: boolean; }): Element', gave the following error.
!!! error TS2763: Type 'string' is not assignable to type 'boolean'.
!!! related TS6500 tests/cases/conformance/jsx/file.tsx:28:38: The expected type comes from property 'y1' which is declared here on type 'IntrinsicAttributes & { y1?: string; y2?: number; }'
!!! related TS6500 tests/cases/conformance/jsx/file.tsx:29:38: The expected type comes from property 'y1' which is declared here on type 'IntrinsicAttributes & { y1?: string; y2?: number; children: Element; }'
!!! related TS6500 tests/cases/conformance/jsx/file.tsx:30:64: The expected type comes from property 'y3' which is declared here on type 'IntrinsicAttributes & { y1: boolean; y2?: number; y3: boolean; }'
const e2 = <TestingOptional y1="hello" y2={1000} y3 />
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2763: No overload matches this call.
@@ -180,6 +188,7 @@ tests/cases/conformance/jsx/file.tsx(36,12): error TS2763: No overload matches t
!!! error TS2763: Property 'y3' does not exist on type 'IntrinsicAttributes & { y1?: string; y2?: number; children: Element; }'.
!!! error TS2763: Overload 3 of 3, '(a: { y1: boolean; y2?: number; y3: boolean; }): Element', gave the following error.
!!! error TS2763: Type 'string' is not assignable to type 'boolean'.
!!! related TS6500 tests/cases/conformance/jsx/file.tsx:30:38: The expected type comes from property 'y1' which is declared here on type 'IntrinsicAttributes & { y1: boolean; y2?: number; y3: boolean; }'
const e3 = <TestingOptional y1="hello" y2={1000} children="hi" />
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2763: No overload matches this call.
@@ -190,6 +199,8 @@ tests/cases/conformance/jsx/file.tsx(36,12): error TS2763: No overload matches t
!!! error TS2763: Type 'string' is not assignable to type 'Element'.
!!! error TS2763: Overload 3 of 3, '(a: { y1: boolean; y2?: number; y3: boolean; }): Element', gave the following error.
!!! error TS2763: Type 'string' is not assignable to type 'boolean'.
!!! related TS6500 tests/cases/conformance/jsx/file.tsx:29:64: The expected type comes from property 'children' which is declared here on type 'IntrinsicAttributes & { y1?: string; y2?: number; children: Element; }'
!!! related TS6500 tests/cases/conformance/jsx/file.tsx:30:38: The expected type comes from property 'y1' which is declared here on type 'IntrinsicAttributes & { y1: boolean; y2?: number; y3: boolean; }'
const e4 = <TestingOptional y1="hello" y2={1000}>Hi</TestingOptional>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2763: No overload matches this call.
@@ -200,4 +211,6 @@ tests/cases/conformance/jsx/file.tsx(36,12): error TS2763: No overload matches t
!!! error TS2763: 'TestingOptional' components don't accept text as child elements. Text in JSX has the type 'string', but the expected type of 'children' is 'Element'.
!!! error TS2763: Overload 3 of 3, '(a: { y1: boolean; y2?: number; y3: boolean; }): Element', gave the following error.
!!! error TS2763: Type 'string' is not assignable to type 'boolean'.
!!! related TS6500 tests/cases/conformance/jsx/file.tsx:29:64: The expected type comes from property 'children' which is declared here on type 'IntrinsicAttributes & { y1?: string; y2?: number; children: Element; }'
!!! related TS6500 tests/cases/conformance/jsx/file.tsx:30:38: The expected type comes from property 'y1' which is declared here on type 'IntrinsicAttributes & { y1: boolean; y2?: number; y3: boolean; }'
@@ -105,6 +105,9 @@ tests/cases/conformance/jsx/file.tsx(56,12): error TS2763: No overload matches t
!!! error TS2763: Type 'number' is not assignable to type 'string'.
!!! error TS2763: Overload 3 of 3, '(hyphenProps: HyphenProps): Element', gave the following error.
!!! error TS2763: Type 'number' is not assignable to type 'string'.
!!! related TS6500 tests/cases/conformance/jsx/file.tsx:4:5: The expected type comes from property 'children' which is declared here on type 'IntrinsicAttributes & ButtonProps'
!!! related TS6500 tests/cases/conformance/jsx/file.tsx:4:5: The expected type comes from property 'children' which is declared here on type 'IntrinsicAttributes & LinkProps'
!!! related TS6500 tests/cases/conformance/jsx/file.tsx:4:5: The expected type comes from property 'children' which is declared here on type 'IntrinsicAttributes & HyphenProps'
const b7 = <MainButton {...{ onClick(e: any){} }} children="hello" className />; // incorrect type for optional attribute
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2763: No overload matches this call.
@@ -114,6 +117,9 @@ tests/cases/conformance/jsx/file.tsx(56,12): error TS2763: No overload matches t
!!! error TS2763: Type 'true' is not assignable to type 'string'.
!!! error TS2763: Overload 3 of 3, '(hyphenProps: HyphenProps): Element', gave the following error.
!!! error TS2763: Type 'true' is not assignable to type 'string'.
!!! related TS6500 tests/cases/conformance/jsx/file.tsx:5:5: The expected type comes from property 'className' which is declared here on type 'IntrinsicAttributes & ButtonProps'
!!! related TS6500 tests/cases/conformance/jsx/file.tsx:5:5: The expected type comes from property 'className' which is declared here on type 'IntrinsicAttributes & LinkProps'
!!! related TS6500 tests/cases/conformance/jsx/file.tsx:5:5: The expected type comes from property 'className' which is declared here on type 'IntrinsicAttributes & HyphenProps'
const b8 = <MainButton data-format />; // incorrect type for specified hyphanated name
~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2763: No overload matches this call.
@@ -122,4 +128,7 @@ tests/cases/conformance/jsx/file.tsx(56,12): error TS2763: No overload matches t
!!! error TS2763: Overload 2 of 3, '(linkProps: LinkProps): Element', gave the following error.
!!! error TS2763: Property 'to' is missing in type '{ data-format: true; }' but required in type 'LinkProps'.
!!! error TS2763: Overload 3 of 3, '(hyphenProps: HyphenProps): Element', gave the following error.
!!! error TS2763: Type 'true' is not assignable to type 'string'.
!!! error TS2763: Type 'true' is not assignable to type 'string'.
!!! related TS2728 tests/cases/conformance/jsx/file.tsx:9:5: 'onClick' is declared here.
!!! related TS2728 tests/cases/conformance/jsx/file.tsx:13:5: 'to' is declared here.
!!! related TS6500 tests/cases/conformance/jsx/file.tsx:17:5: The expected type comes from property 'data-format' which is declared here on type 'IntrinsicAttributes & HyphenProps'
@@ -36,6 +36,8 @@ tests/cases/conformance/jsx/file.tsx(10,14): error TS2763: No overload matches t
!!! error TS2763: Type 'number' is not assignable to type 'string'.
!!! error TS2763: Overload 3 of 3, '(attr: { b: unknown; a: number; }): Element', gave the following error.
!!! error TS2763: Property 'b' is missing in type '{ a: number; }' but required in type '{ b: unknown; a: number; }'.
!!! related TS6500 tests/cases/conformance/jsx/file.tsx:4:52: The expected type comes from property 'a' which is declared here on type 'IntrinsicAttributes & { b: unknown; a: string; "ignore-prop": boolean; }'
!!! related TS2728 tests/cases/conformance/jsx/file.tsx:5:49: 'b' is declared here.
let a2 = <OverloadComponent {...arg1} ignore-prop /> // missing a
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2763: No overload matches this call.
@@ -47,4 +49,6 @@ tests/cases/conformance/jsx/file.tsx(10,14): error TS2763: No overload matches t
!!! error TS2763: Overload 3 of 3, '(attr: { b: unknown; a: unknown; }): Element', gave the following error.
!!! error TS2763: Type 'T & { ignore-prop: true; }' is not assignable to type 'IntrinsicAttributes & { b: unknown; a: unknown; }'.
!!! error TS2763: Property 'a' is missing in type '{ b: number; } & { ignore-prop: true; }' but required in type '{ b: unknown; a: unknown; }'.
!!! related TS2728 tests/cases/conformance/jsx/file.tsx:4:52: 'a' is declared here.
!!! related TS2728 tests/cases/conformance/jsx/file.tsx:5:55: 'a' is declared here.
}