TypeScript/tests/cases/fourslash/tsxQuickInfo7.ts
Wesley Wigham 7b5ef64e76
Unify JSX And Normal Call Checking Codepaths (#27627)
* Unify JSX Call Checking Codepaths

* Add tests for fixed issues

* Fix lint, move all error checking into the only-run-once resolveSignature call

* Remove unused (unreachable?) code path

* Consolidate a little more duplicated logic into signature checking

* Fix #19775 a bit more

* Cosmetic changes from CR
2018-10-16 20:16:00 -04:00

29 lines
2 KiB
TypeScript

/// <reference path='fourslash.ts' />
//@Filename: file.tsx
// @jsx: preserve
// @noLib: true
//// declare function OverloadComponent<U>(attr: {b: U, a?: string, "ignore-prop": boolean}): JSX.Element;
//// declare function OverloadComponent<T, U>(attr: {b: U, a: T}): JSX.Element;
//// declare function OverloadComponent(): JSX.Element; // effective argument type of `{}`, needs to be last
//// function Baz<T extends {b: number}, U extends {a: boolean, b:string}>(arg1: T, arg2: U) {
//// let a0 = <Overloa/*1*/dComponent {...arg1} a="hello" ignore-prop />;
//// let a1 = <Overloa/*2*/dComponent {...arg2} ignore-pro="hello world" />;
//// let a2 = <Overloa/*3*/dComponent {...arg2} />;
//// let a3 = <Overloa/*4*/dComponent {...arg1} ignore-prop />;
//// let a4 = <Overloa/*5*/dComponent />;
//// let a5 = <Overloa/*6*/dComponent {...arg2} ignore-prop="hello" {...arg1} />;
//// let a6 = <Overloa/*7*/dComponent {...arg1} ignore-prop {...arg2} />;
//// }
verify.quickInfos({
1: "function OverloadComponent<number>(attr: {\n b: number;\n a?: string;\n \"ignore-prop\": boolean;\n}): any (+2 overloads)",
2: "function OverloadComponent<boolean, string>(attr: {\n b: string;\n a: boolean;\n}): any (+2 overloads)",
3: "function OverloadComponent<boolean, string>(attr: {\n b: string;\n a: boolean;\n}): any (+2 overloads)",
4: "function OverloadComponent(): any (+2 overloads)", // Subtype pass chooses this overload, since `a` is missing from the top overload, and `ignore-prop` is missing from the second (while T & {ignore-prop: true} is a proper subtype of `{}`)
5: "function OverloadComponent(): any (+2 overloads)",
6: "function OverloadComponent<boolean, string & number>(attr: {\n b: string & number;\n a: boolean;\n}): any (+2 overloads)",
7: "function OverloadComponent<boolean, number & string>(attr: {\n b: number & string;\n a: boolean;\n}): any (+2 overloads)",
});