Allow union signatures to merge when they have differing argument counts (#28604)

* Allow union signatures to merge when they have differing argument counts

* Accept updated baselines

* Adjust comments io changed tests
This commit is contained in:
Wesley Wigham authored and GitHub committed 2018-11-19 17:05:28 -08:00
1 parent ddded2df7c
commit 96937fd592
21 files changed
+362 -191

No files matched your search

+2 -7
View File
@@ -13105,13 +13105,8 @@ namespace ts {
return true;
}
// A source signature partially matches a target signature if the target signature has no fewer required
// parameters and no more overall parameters than the source signature (where a signature with a rest
// parameter is always considered to have more overall parameters than one without).
const sourceRestCount = sourceHasRestParameter ? 1 : 0;
const targetRestCount = targetHasRestParameter ? 1 : 0;
if (partialMatch && sourceMinArgumentCount <= targetMinArgumentCount && (
sourceRestCount > targetRestCount ||
sourceRestCount === targetRestCount && sourceParameterCount >= targetParameterCount)) {
// parameters
if (partialMatch && sourceMinArgumentCount <= targetMinArgumentCount) {
return true;
}
return false;
@@ -0,0 +1,41 @@
//// [reactSFCAndFunctionResolvable.tsx]
/// <reference path="/.lib/react16.d.ts" />
import * as React from 'react';
declare const Radio: (props: {}) => React.ReactElement<{}>;
declare const OtherRadio: () => React.ReactElement<{}>;
declare const Checkbox: React.SFC;
declare const condition1: boolean;
declare const condition2: boolean;
declare const condition3: boolean;
const RandomComponent: React.SFC = () => {
const Component =
condition1
? Radio
: Checkbox;
const OtherComponent =
condition2
? OtherRadio
: Checkbox;
return condition1 ? <Component /> : <OtherComponent />;
};
//// [reactSFCAndFunctionResolvable.js]
"use strict";
/// <reference path="react16.d.ts" />
exports.__esModule = true;
var React = require("react");
var RandomComponent = function () {
var Component = condition1
? Radio
: Checkbox;
var OtherComponent = condition2
? OtherRadio
: Checkbox;
return condition1 ? React.createElement(Component, null) : React.createElement(OtherComponent, null);
};
@@ -0,0 +1,67 @@
=== tests/cases/compiler/reactSFCAndFunctionResolvable.tsx ===
/// <reference path="react16.d.ts" />
import * as React from 'react';
>React : Symbol(React, Decl(reactSFCAndFunctionResolvable.tsx, 2, 6))
declare const Radio: (props: {}) => React.ReactElement<{}>;
>Radio : Symbol(Radio, Decl(reactSFCAndFunctionResolvable.tsx, 4, 13))
>props : Symbol(props, Decl(reactSFCAndFunctionResolvable.tsx, 4, 22))
>React : Symbol(React, Decl(reactSFCAndFunctionResolvable.tsx, 2, 6))
>ReactElement : Symbol(React.ReactElement, Decl(react16.d.ts, 135, 9))
declare const OtherRadio: () => React.ReactElement<{}>;
>OtherRadio : Symbol(OtherRadio, Decl(reactSFCAndFunctionResolvable.tsx, 5, 13))
>React : Symbol(React, Decl(reactSFCAndFunctionResolvable.tsx, 2, 6))
>ReactElement : Symbol(React.ReactElement, Decl(react16.d.ts, 135, 9))
declare const Checkbox: React.SFC;
>Checkbox : Symbol(Checkbox, Decl(reactSFCAndFunctionResolvable.tsx, 6, 13))
>React : Symbol(React, Decl(reactSFCAndFunctionResolvable.tsx, 2, 6))
>SFC : Symbol(React.SFC, Decl(react16.d.ts, 400, 9))
declare const condition1: boolean;
>condition1 : Symbol(condition1, Decl(reactSFCAndFunctionResolvable.tsx, 8, 13))
declare const condition2: boolean;
>condition2 : Symbol(condition2, Decl(reactSFCAndFunctionResolvable.tsx, 9, 13))
declare const condition3: boolean;
>condition3 : Symbol(condition3, Decl(reactSFCAndFunctionResolvable.tsx, 10, 13))
const RandomComponent: React.SFC = () => {
>RandomComponent : Symbol(RandomComponent, Decl(reactSFCAndFunctionResolvable.tsx, 12, 5))
>React : Symbol(React, Decl(reactSFCAndFunctionResolvable.tsx, 2, 6))
>SFC : Symbol(React.SFC, Decl(react16.d.ts, 400, 9))
const Component =
>Component : Symbol(Component, Decl(reactSFCAndFunctionResolvable.tsx, 13, 7))
condition1
>condition1 : Symbol(condition1, Decl(reactSFCAndFunctionResolvable.tsx, 8, 13))
? Radio
>Radio : Symbol(Radio, Decl(reactSFCAndFunctionResolvable.tsx, 4, 13))
: Checkbox;
>Checkbox : Symbol(Checkbox, Decl(reactSFCAndFunctionResolvable.tsx, 6, 13))
const OtherComponent =
>OtherComponent : Symbol(OtherComponent, Decl(reactSFCAndFunctionResolvable.tsx, 18, 7))
condition2
>condition2 : Symbol(condition2, Decl(reactSFCAndFunctionResolvable.tsx, 9, 13))
? OtherRadio
>OtherRadio : Symbol(OtherRadio, Decl(reactSFCAndFunctionResolvable.tsx, 5, 13))
: Checkbox;
>Checkbox : Symbol(Checkbox, Decl(reactSFCAndFunctionResolvable.tsx, 6, 13))
return condition1 ? <Component /> : <OtherComponent />;
>condition1 : Symbol(condition1, Decl(reactSFCAndFunctionResolvable.tsx, 8, 13))
>Component : Symbol(Component, Decl(reactSFCAndFunctionResolvable.tsx, 13, 7))
>OtherComponent : Symbol(OtherComponent, Decl(reactSFCAndFunctionResolvable.tsx, 18, 7))
};
@@ -0,0 +1,69 @@
=== tests/cases/compiler/reactSFCAndFunctionResolvable.tsx ===
/// <reference path="react16.d.ts" />
import * as React from 'react';
>React : typeof React
declare const Radio: (props: {}) => React.ReactElement<{}>;
>Radio : (props: {}) => React.ReactElement<{}>
>props : {}
>React : any
declare const OtherRadio: () => React.ReactElement<{}>;
>OtherRadio : () => React.ReactElement<{}>
>React : any
declare const Checkbox: React.SFC;
>Checkbox : React.StatelessComponent<{}>
>React : any
declare const condition1: boolean;
>condition1 : boolean
declare const condition2: boolean;
>condition2 : boolean
declare const condition3: boolean;
>condition3 : boolean
const RandomComponent: React.SFC = () => {
>RandomComponent : React.StatelessComponent<{}>
>React : any
>() => { const Component = condition1 ? Radio : Checkbox; const OtherComponent = condition2 ? OtherRadio : Checkbox; return condition1 ? <Component /> : <OtherComponent />;} : () => JSX.Element
const Component =
>Component : React.StatelessComponent<{}> | ((props: {}) => React.ReactElement<{}>)
condition1
>condition1 ? Radio : Checkbox : React.StatelessComponent<{}> | ((props: {}) => React.ReactElement<{}>)
>condition1 : boolean
? Radio
>Radio : (props: {}) => React.ReactElement<{}>
: Checkbox;
>Checkbox : React.StatelessComponent<{}>
const OtherComponent =
>OtherComponent : React.StatelessComponent<{}> | (() => React.ReactElement<{}>)
condition2
>condition2 ? OtherRadio : Checkbox : React.StatelessComponent<{}> | (() => React.ReactElement<{}>)
>condition2 : boolean
? OtherRadio
>OtherRadio : () => React.ReactElement<{}>
: Checkbox;
>Checkbox : React.StatelessComponent<{}>
return condition1 ? <Component /> : <OtherComponent />;
>condition1 ? <Component /> : <OtherComponent /> : JSX.Element
>condition1 : boolean
><Component /> : JSX.Element
>Component : React.StatelessComponent<{}> | ((props: {}) => React.ReactElement<{}>)
><OtherComponent /> : JSX.Element
>OtherComponent : React.StatelessComponent<{}> | (() => React.ReactElement<{}>)
};
@@ -7,31 +7,27 @@ tests/cases/conformance/types/union/unionTypeCallSignatures.ts(20,1): error TS23
tests/cases/conformance/types/union/unionTypeCallSignatures.ts(21,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((a: number) => number) | ((a: string) => Date)' has no compatible call signatures.
tests/cases/conformance/types/union/unionTypeCallSignatures.ts(24,1): error TS2554: Expected 1 arguments, but got 0.
tests/cases/conformance/types/union/unionTypeCallSignatures.ts(26,36): error TS2345: Argument of type '"hello"' is not assignable to parameter of type 'number'.
tests/cases/conformance/types/union/unionTypeCallSignatures.ts(29,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((a: string) => string) | ((a: string, b: number) => number)' has no compatible call signatures.
tests/cases/conformance/types/union/unionTypeCallSignatures.ts(30,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((a: string) => string) | ((a: string, b: number) => number)' has no compatible call signatures.
tests/cases/conformance/types/union/unionTypeCallSignatures.ts(31,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((a: string) => string) | ((a: string, b: number) => number)' has no compatible call signatures.
tests/cases/conformance/types/union/unionTypeCallSignatures.ts(29,1): error TS2554: Expected 2 arguments, but got 0.
tests/cases/conformance/types/union/unionTypeCallSignatures.ts(30,1): error TS2554: Expected 2 arguments, but got 1.
tests/cases/conformance/types/union/unionTypeCallSignatures.ts(36,49): error TS2345: Argument of type '"hello"' is not assignable to parameter of type 'number'.
tests/cases/conformance/types/union/unionTypeCallSignatures.ts(37,12): error TS2554: Expected 1-2 arguments, but got 0.
tests/cases/conformance/types/union/unionTypeCallSignatures.ts(40,12): error TS2554: Expected 2 arguments, but got 1.
tests/cases/conformance/types/union/unionTypeCallSignatures.ts(42,49): error TS2345: Argument of type '"hello"' is not assignable to parameter of type 'number'.
tests/cases/conformance/types/union/unionTypeCallSignatures.ts(43,12): error TS2554: Expected 2 arguments, but got 0.
tests/cases/conformance/types/union/unionTypeCallSignatures.ts(47,12): error TS2554: Expected 1 arguments, but got 2.
tests/cases/conformance/types/union/unionTypeCallSignatures.ts(48,12): error TS2554: Expected 1 arguments, but got 2.
tests/cases/conformance/types/union/unionTypeCallSignatures.ts(49,12): error TS2554: Expected 1 arguments, but got 0.
tests/cases/conformance/types/union/unionTypeCallSignatures.ts(48,49): error TS2345: Argument of type '"hello"' is not assignable to parameter of type 'number'.
tests/cases/conformance/types/union/unionTypeCallSignatures.ts(49,12): error TS2554: Expected 1-2 arguments, but got 0.
tests/cases/conformance/types/union/unionTypeCallSignatures.ts(55,45): error TS2345: Argument of type '"hello"' is not assignable to parameter of type 'number'.
tests/cases/conformance/types/union/unionTypeCallSignatures.ts(56,12): error TS2555: Expected at least 1 arguments, but got 0.
tests/cases/conformance/types/union/unionTypeCallSignatures.ts(59,12): error TS2554: Expected 2 arguments, but got 1.
tests/cases/conformance/types/union/unionTypeCallSignatures.ts(61,12): error TS2554: Expected 2 arguments, but got 3.
tests/cases/conformance/types/union/unionTypeCallSignatures.ts(62,45): error TS2345: Argument of type '"hello"' is not assignable to parameter of type 'number'.
tests/cases/conformance/types/union/unionTypeCallSignatures.ts(63,12): error TS2554: Expected 2 arguments, but got 0.
tests/cases/conformance/types/union/unionTypeCallSignatures.ts(67,12): error TS2554: Expected 1 arguments, but got 2.
tests/cases/conformance/types/union/unionTypeCallSignatures.ts(68,12): error TS2554: Expected 1 arguments, but got 3.
tests/cases/conformance/types/union/unionTypeCallSignatures.ts(69,12): error TS2554: Expected 1 arguments, but got 2.
tests/cases/conformance/types/union/unionTypeCallSignatures.ts(70,12): error TS2554: Expected 1 arguments, but got 0.
tests/cases/conformance/types/union/unionTypeCallSignatures.ts(69,45): error TS2345: Argument of type '"hello"' is not assignable to parameter of type 'number'.
tests/cases/conformance/types/union/unionTypeCallSignatures.ts(70,12): error TS2555: Expected at least 1 arguments, but got 0.
tests/cases/conformance/types/union/unionTypeCallSignatures.ts(73,12): error TS2554: Expected 2 arguments, but got 1.
==== tests/cases/conformance/types/union/unionTypeCallSignatures.ts (31 errors) ====
==== tests/cases/conformance/types/union/unionTypeCallSignatures.ts (27 errors) ====
var numOrDate: number | Date;
var strOrBoolean: string | boolean;
var strOrNum: string | number;
@@ -80,15 +76,15 @@ tests/cases/conformance/types/union/unionTypeCallSignatures.ts(73,12): error TS2
!!! error TS2345: Argument of type '"hello"' is not assignable to parameter of type 'number'.
var unionWithDifferentParameterCount: { (a: string): string; } | { (a: string, b: number): number; } ;
unionWithDifferentParameterCount();// no call signature
unionWithDifferentParameterCount();// needs more args
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((a: string) => string) | ((a: string, b: number) => number)' has no compatible call signatures.
unionWithDifferentParameterCount("hello");// no call signature
!!! error TS2554: Expected 2 arguments, but got 0.
!!! related TS6210 tests/cases/conformance/types/union/unionTypeCallSignatures.ts:28:69: An argument for 'a' was not provided.
unionWithDifferentParameterCount("hello");// needs more args
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((a: string) => string) | ((a: string, b: number) => number)' has no compatible call signatures.
unionWithDifferentParameterCount("hello", 10);// no call signature
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((a: string) => string) | ((a: string, b: number) => number)' has no compatible call signatures.
!!! error TS2554: Expected 2 arguments, but got 1.
!!! related TS6210 tests/cases/conformance/types/union/unionTypeCallSignatures.ts:28:80: An argument for 'b' was not provided.
unionWithDifferentParameterCount("hello", 10);// OK
var unionWithOptionalParameter1: { (a: string, b?: number): string; } | { (a: string, b?: number): number; };
strOrNum = unionWithOptionalParameter1('hello');
@@ -117,16 +113,14 @@ tests/cases/conformance/types/union/unionTypeCallSignatures.ts(73,12): error TS2
var unionWithOptionalParameter3: { (a: string, b?: number): string; } | { (a: string): number; };
strOrNum = unionWithOptionalParameter3('hello');
strOrNum = unionWithOptionalParameter3('hello', 10); // error no call signature
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2554: Expected 1 arguments, but got 2.
strOrNum = unionWithOptionalParameter3('hello', "hello"); // error no call signature
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2554: Expected 1 arguments, but got 2.
strOrNum = unionWithOptionalParameter3(); // error no call signature
strOrNum = unionWithOptionalParameter3('hello', 10); // ok
strOrNum = unionWithOptionalParameter3('hello', "hello"); // wrong argument type
~~~~~~~
!!! error TS2345: Argument of type '"hello"' is not assignable to parameter of type 'number'.
strOrNum = unionWithOptionalParameter3(); // needs more args
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2554: Expected 1 arguments, but got 0.
!!! related TS6210 tests/cases/conformance/types/union/unionTypeCallSignatures.ts:45:76: An argument for 'a' was not provided.
!!! error TS2554: Expected 1-2 arguments, but got 0.
!!! related TS6210 tests/cases/conformance/types/union/unionTypeCallSignatures.ts:45:37: An argument for 'a' was not provided.
var unionWithRestParameter1: { (a: string, ...b: number[]): string; } | { (a: string, ...b: number[]): number };
strOrNum = unionWithRestParameter1('hello');
@@ -160,18 +154,14 @@ tests/cases/conformance/types/union/unionTypeCallSignatures.ts(73,12): error TS2
var unionWithRestParameter3: { (a: string, ...b: number[]): string; } | { (a: string): number };
strOrNum = unionWithRestParameter3('hello');
strOrNum = unionWithRestParameter3('hello', 10); // error no call signature
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2554: Expected 1 arguments, but got 2.
strOrNum = unionWithRestParameter3('hello', 10, 11); // error no call signature
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2554: Expected 1 arguments, but got 3.
strOrNum = unionWithRestParameter3('hello', "hello"); // error no call signature
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2554: Expected 1 arguments, but got 2.
strOrNum = unionWithRestParameter3('hello', "hello"); // wrong argument type
~~~~~~~
!!! error TS2345: Argument of type '"hello"' is not assignable to parameter of type 'number'.
strOrNum = unionWithRestParameter3(); // error no call signature
~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2554: Expected 1 arguments, but got 0.
!!! related TS6210 tests/cases/conformance/types/union/unionTypeCallSignatures.ts:65:76: An argument for 'a' was not provided.
!!! error TS2555: Expected at least 1 arguments, but got 0.
!!! related TS6210 tests/cases/conformance/types/union/unionTypeCallSignatures.ts:65:33: An argument for 'a' was not provided.
var unionWithRestParameter4: { (...a: string[]): string; } | { (a: string, b: string): number; };
strOrNum = unionWithRestParameter4("hello"); // error supplied parameters do not match any call signature
@@ -27,9 +27,9 @@ unionOfDifferentNumberOfSignatures(10); // error - no call signatures
unionOfDifferentNumberOfSignatures("hello"); // error - no call signatures
var unionWithDifferentParameterCount: { (a: string): string; } | { (a: string, b: number): number; } ;
unionWithDifferentParameterCount();// no call signature
unionWithDifferentParameterCount("hello");// no call signature
unionWithDifferentParameterCount("hello", 10);// no call signature
unionWithDifferentParameterCount();// needs more args
unionWithDifferentParameterCount("hello");// needs more args
unionWithDifferentParameterCount("hello", 10);// OK
var unionWithOptionalParameter1: { (a: string, b?: number): string; } | { (a: string, b?: number): number; };
strOrNum = unionWithOptionalParameter1('hello');
@@ -45,9 +45,9 @@ strOrNum = unionWithOptionalParameter2(); // error no call signature
var unionWithOptionalParameter3: { (a: string, b?: number): string; } | { (a: string): number; };
strOrNum = unionWithOptionalParameter3('hello');
strOrNum = unionWithOptionalParameter3('hello', 10); // error no call signature
strOrNum = unionWithOptionalParameter3('hello', "hello"); // error no call signature
strOrNum = unionWithOptionalParameter3(); // error no call signature
strOrNum = unionWithOptionalParameter3('hello', 10); // ok
strOrNum = unionWithOptionalParameter3('hello', "hello"); // wrong argument type
strOrNum = unionWithOptionalParameter3(); // needs more args
var unionWithRestParameter1: { (a: string, ...b: number[]): string; } | { (a: string, ...b: number[]): number };
strOrNum = unionWithRestParameter1('hello');
@@ -67,7 +67,7 @@ var unionWithRestParameter3: { (a: string, ...b: number[]): string; } | { (a: st
strOrNum = unionWithRestParameter3('hello');
strOrNum = unionWithRestParameter3('hello', 10); // error no call signature
strOrNum = unionWithRestParameter3('hello', 10, 11); // error no call signature
strOrNum = unionWithRestParameter3('hello', "hello"); // error no call signature
strOrNum = unionWithRestParameter3('hello', "hello"); // wrong argument type
strOrNum = unionWithRestParameter3(); // error no call signature
var unionWithRestParameter4: { (...a: string[]): string; } | { (a: string, b: string): number; };
@@ -99,9 +99,9 @@ unionOfDifferentNumberOfSignatures(); // error - no call signatures
unionOfDifferentNumberOfSignatures(10); // error - no call signatures
unionOfDifferentNumberOfSignatures("hello"); // error - no call signatures
var unionWithDifferentParameterCount;
unionWithDifferentParameterCount(); // no call signature
unionWithDifferentParameterCount("hello"); // no call signature
unionWithDifferentParameterCount("hello", 10); // no call signature
unionWithDifferentParameterCount(); // needs more args
unionWithDifferentParameterCount("hello"); // needs more args
unionWithDifferentParameterCount("hello", 10); // OK
var unionWithOptionalParameter1;
strOrNum = unionWithOptionalParameter1('hello');
strOrNum = unionWithOptionalParameter1('hello', 10);
@@ -114,9 +114,9 @@ strOrNum = unionWithOptionalParameter2('hello', "hello"); // error no call signa
strOrNum = unionWithOptionalParameter2(); // error no call signature
var unionWithOptionalParameter3;
strOrNum = unionWithOptionalParameter3('hello');
strOrNum = unionWithOptionalParameter3('hello', 10); // error no call signature
strOrNum = unionWithOptionalParameter3('hello', "hello"); // error no call signature
strOrNum = unionWithOptionalParameter3(); // error no call signature
strOrNum = unionWithOptionalParameter3('hello', 10); // ok
strOrNum = unionWithOptionalParameter3('hello', "hello"); // wrong argument type
strOrNum = unionWithOptionalParameter3(); // needs more args
var unionWithRestParameter1;
strOrNum = unionWithRestParameter1('hello');
strOrNum = unionWithRestParameter1('hello', 10);
@@ -133,7 +133,7 @@ var unionWithRestParameter3;
strOrNum = unionWithRestParameter3('hello');
strOrNum = unionWithRestParameter3('hello', 10); // error no call signature
strOrNum = unionWithRestParameter3('hello', 10, 11); // error no call signature
strOrNum = unionWithRestParameter3('hello', "hello"); // error no call signature
strOrNum = unionWithRestParameter3('hello', "hello"); // wrong argument type
strOrNum = unionWithRestParameter3(); // error no call signature
var unionWithRestParameter4;
strOrNum = unionWithRestParameter4("hello"); // error supplied parameters do not match any call signature
@@ -87,13 +87,13 @@ var unionWithDifferentParameterCount: { (a: string): string; } | { (a: string, b
>a : Symbol(a, Decl(unionTypeCallSignatures.ts, 27, 68))
>b : Symbol(b, Decl(unionTypeCallSignatures.ts, 27, 78))
unionWithDifferentParameterCount();// no call signature
unionWithDifferentParameterCount();// needs more args
>unionWithDifferentParameterCount : Symbol(unionWithDifferentParameterCount, Decl(unionTypeCallSignatures.ts, 27, 3))
unionWithDifferentParameterCount("hello");// no call signature
unionWithDifferentParameterCount("hello");// needs more args
>unionWithDifferentParameterCount : Symbol(unionWithDifferentParameterCount, Decl(unionTypeCallSignatures.ts, 27, 3))
unionWithDifferentParameterCount("hello", 10);// no call signature
unionWithDifferentParameterCount("hello", 10);// OK
>unionWithDifferentParameterCount : Symbol(unionWithDifferentParameterCount, Decl(unionTypeCallSignatures.ts, 27, 3))
var unionWithOptionalParameter1: { (a: string, b?: number): string; } | { (a: string, b?: number): number; };
@@ -152,15 +152,15 @@ strOrNum = unionWithOptionalParameter3('hello');
>strOrNum : Symbol(strOrNum, Decl(unionTypeCallSignatures.ts, 2, 3))
>unionWithOptionalParameter3 : Symbol(unionWithOptionalParameter3, Decl(unionTypeCallSignatures.ts, 44, 3))
strOrNum = unionWithOptionalParameter3('hello', 10); // error no call signature
strOrNum = unionWithOptionalParameter3('hello', 10); // ok
>strOrNum : Symbol(strOrNum, Decl(unionTypeCallSignatures.ts, 2, 3))
>unionWithOptionalParameter3 : Symbol(unionWithOptionalParameter3, Decl(unionTypeCallSignatures.ts, 44, 3))
strOrNum = unionWithOptionalParameter3('hello', "hello"); // error no call signature
strOrNum = unionWithOptionalParameter3('hello', "hello"); // wrong argument type
>strOrNum : Symbol(strOrNum, Decl(unionTypeCallSignatures.ts, 2, 3))
>unionWithOptionalParameter3 : Symbol(unionWithOptionalParameter3, Decl(unionTypeCallSignatures.ts, 44, 3))
strOrNum = unionWithOptionalParameter3(); // error no call signature
strOrNum = unionWithOptionalParameter3(); // needs more args
>strOrNum : Symbol(strOrNum, Decl(unionTypeCallSignatures.ts, 2, 3))
>unionWithOptionalParameter3 : Symbol(unionWithOptionalParameter3, Decl(unionTypeCallSignatures.ts, 44, 3))
@@ -236,7 +236,7 @@ strOrNum = unionWithRestParameter3('hello', 10, 11); // error no call signature
>strOrNum : Symbol(strOrNum, Decl(unionTypeCallSignatures.ts, 2, 3))
>unionWithRestParameter3 : Symbol(unionWithRestParameter3, Decl(unionTypeCallSignatures.ts, 64, 3))
strOrNum = unionWithRestParameter3('hello', "hello"); // error no call signature
strOrNum = unionWithRestParameter3('hello', "hello"); // wrong argument type
>strOrNum : Symbol(strOrNum, Decl(unionTypeCallSignatures.ts, 2, 3))
>unionWithRestParameter3 : Symbol(unionWithRestParameter3, Decl(unionTypeCallSignatures.ts, 64, 3))
@@ -109,17 +109,17 @@ var unionWithDifferentParameterCount: { (a: string): string; } | { (a: string, b
>a : string
>b : number
unionWithDifferentParameterCount();// no call signature
unionWithDifferentParameterCount();// needs more args
>unionWithDifferentParameterCount() : any
>unionWithDifferentParameterCount : ((a: string) => string) | ((a: string, b: number) => number)
unionWithDifferentParameterCount("hello");// no call signature
unionWithDifferentParameterCount("hello");// needs more args
>unionWithDifferentParameterCount("hello") : any
>unionWithDifferentParameterCount : ((a: string) => string) | ((a: string, b: number) => number)
>"hello" : "hello"
unionWithDifferentParameterCount("hello", 10);// no call signature
>unionWithDifferentParameterCount("hello", 10) : any
unionWithDifferentParameterCount("hello", 10);// OK
>unionWithDifferentParameterCount("hello", 10) : string | number
>unionWithDifferentParameterCount : ((a: string) => string) | ((a: string, b: number) => number)
>"hello" : "hello"
>10 : 10
@@ -209,15 +209,15 @@ strOrNum = unionWithOptionalParameter3('hello');
>unionWithOptionalParameter3 : ((a: string, b?: number) => string) | ((a: string) => number)
>'hello' : "hello"
strOrNum = unionWithOptionalParameter3('hello', 10); // error no call signature
>strOrNum = unionWithOptionalParameter3('hello', 10) : any
strOrNum = unionWithOptionalParameter3('hello', 10); // ok
>strOrNum = unionWithOptionalParameter3('hello', 10) : string | number
>strOrNum : string | number
>unionWithOptionalParameter3('hello', 10) : any
>unionWithOptionalParameter3('hello', 10) : string | number
>unionWithOptionalParameter3 : ((a: string, b?: number) => string) | ((a: string) => number)
>'hello' : "hello"
>10 : 10
strOrNum = unionWithOptionalParameter3('hello', "hello"); // error no call signature
strOrNum = unionWithOptionalParameter3('hello', "hello"); // wrong argument type
>strOrNum = unionWithOptionalParameter3('hello', "hello") : any
>strOrNum : string | number
>unionWithOptionalParameter3('hello', "hello") : any
@@ -225,7 +225,7 @@ strOrNum = unionWithOptionalParameter3('hello', "hello"); // error no call signa
>'hello' : "hello"
>"hello" : "hello"
strOrNum = unionWithOptionalParameter3(); // error no call signature
strOrNum = unionWithOptionalParameter3(); // needs more args
>strOrNum = unionWithOptionalParameter3() : any
>strOrNum : string | number
>unionWithOptionalParameter3() : any
@@ -335,23 +335,23 @@ strOrNum = unionWithRestParameter3('hello');
>'hello' : "hello"
strOrNum = unionWithRestParameter3('hello', 10); // error no call signature
>strOrNum = unionWithRestParameter3('hello', 10) : any
>strOrNum = unionWithRestParameter3('hello', 10) : string | number
>strOrNum : string | number
>unionWithRestParameter3('hello', 10) : any
>unionWithRestParameter3('hello', 10) : string | number
>unionWithRestParameter3 : ((a: string, ...b: number[]) => string) | ((a: string) => number)
>'hello' : "hello"
>10 : 10
strOrNum = unionWithRestParameter3('hello', 10, 11); // error no call signature
>strOrNum = unionWithRestParameter3('hello', 10, 11) : any
>strOrNum = unionWithRestParameter3('hello', 10, 11) : string | number
>strOrNum : string | number
>unionWithRestParameter3('hello', 10, 11) : any
>unionWithRestParameter3('hello', 10, 11) : string | number
>unionWithRestParameter3 : ((a: string, ...b: number[]) => string) | ((a: string) => number)
>'hello' : "hello"
>10 : 10
>11 : 11
strOrNum = unionWithRestParameter3('hello', "hello"); // error no call signature
strOrNum = unionWithRestParameter3('hello', "hello"); // wrong argument type
>strOrNum = unionWithRestParameter3('hello', "hello") : any
>strOrNum : string | number
>unionWithRestParameter3('hello', "hello") : any
@@ -1,10 +1,8 @@
tests/cases/conformance/types/union/unionTypeCallSignatures4.ts(10,1): error TS2554: Expected 1-2 arguments, but got 3.
tests/cases/conformance/types/union/unionTypeCallSignatures4.ts(20,1): error TS2554: Expected 1-2 arguments, but got 3.
tests/cases/conformance/types/union/unionTypeCallSignatures4.ts(23,1): error TS2554: Expected 2 arguments, but got 1.
tests/cases/conformance/types/union/unionTypeCallSignatures4.ts(25,1): error TS2554: Expected 2 arguments, but got 3.
==== tests/cases/conformance/types/union/unionTypeCallSignatures4.ts (4 errors) ====
==== tests/cases/conformance/types/union/unionTypeCallSignatures4.ts (2 errors) ====
type F1 = (a: string, b?: string) => void;
type F2 = (a: string, b?: string, c?: string) => void;
type F3 = (a: string, ...rest: string[]) => void;
@@ -14,9 +12,7 @@ tests/cases/conformance/types/union/unionTypeCallSignatures4.ts(25,1): error TS2
var f12: F1 | F2;
f12("a");
f12("a", "b");
f12("a", "b", "c"); // error
~~~~~~~~~~~~~~~~~~
!!! error TS2554: Expected 1-2 arguments, but got 3.
f12("a", "b", "c"); // ok
var f34: F3 | F4;
f34("a");
@@ -26,9 +22,7 @@ tests/cases/conformance/types/union/unionTypeCallSignatures4.ts(25,1): error TS2
var f1234: F1 | F2 | F3 | F4;
f1234("a");
f1234("a", "b");
f1234("a", "b", "c"); // error
~~~~~~~~~~~~~~~~~~~~
!!! error TS2554: Expected 1-2 arguments, but got 3.
f1234("a", "b", "c"); // ok
var f12345: F1 | F2 | F3 | F4 | F5;
f12345("a"); // error
@@ -8,7 +8,7 @@ type F5 = (a: string, b: string) => void;
var f12: F1 | F2;
f12("a");
f12("a", "b");
f12("a", "b", "c"); // error
f12("a", "b", "c"); // ok
var f34: F3 | F4;
f34("a");
@@ -18,7 +18,7 @@ f34("a", "b", "c");
var f1234: F1 | F2 | F3 | F4;
f1234("a");
f1234("a", "b");
f1234("a", "b", "c"); // error
f1234("a", "b", "c"); // ok
var f12345: F1 | F2 | F3 | F4 | F5;
f12345("a"); // error
@@ -30,7 +30,7 @@ f12345("a", "b", "c"); // error
var f12;
f12("a");
f12("a", "b");
f12("a", "b", "c"); // error
f12("a", "b", "c"); // ok
var f34;
f34("a");
f34("a", "b");
@@ -38,7 +38,7 @@ f34("a", "b", "c");
var f1234;
f1234("a");
f1234("a", "b");
f1234("a", "b", "c"); // error
f1234("a", "b", "c"); // ok
var f12345;
f12345("a"); // error
f12345("a", "b");
@@ -37,7 +37,7 @@ f12("a");
f12("a", "b");
>f12 : Symbol(f12, Decl(unionTypeCallSignatures4.ts, 6, 3))
f12("a", "b", "c"); // error
f12("a", "b", "c"); // ok
>f12 : Symbol(f12, Decl(unionTypeCallSignatures4.ts, 6, 3))
var f34: F3 | F4;
@@ -67,7 +67,7 @@ f1234("a");
f1234("a", "b");
>f1234 : Symbol(f1234, Decl(unionTypeCallSignatures4.ts, 16, 3))
f1234("a", "b", "c"); // error
f1234("a", "b", "c"); // ok
>f1234 : Symbol(f1234, Decl(unionTypeCallSignatures4.ts, 16, 3))
var f12345: F1 | F2 | F3 | F4 | F5;
@@ -40,8 +40,8 @@ f12("a", "b");
>"a" : "a"
>"b" : "b"
f12("a", "b", "c"); // error
>f12("a", "b", "c") : any
f12("a", "b", "c"); // ok
>f12("a", "b", "c") : void
>f12 : F1 | F2
>"a" : "a"
>"b" : "b"
@@ -82,8 +82,8 @@ f1234("a", "b");
>"a" : "a"
>"b" : "b"
f1234("a", "b", "c"); // error
>f1234("a", "b", "c") : any
f1234("a", "b", "c"); // ok
>f1234("a", "b", "c") : void
>f1234 : F1 | F2 | F3 | F4
>"a" : "a"
>"b" : "b"
@@ -7,30 +7,26 @@ tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(20,1): error
tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(21,1): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(24,1): error TS2554: Expected 1 arguments, but got 0.
tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(26,40): error TS2345: Argument of type '"hello"' is not assignable to parameter of type 'number'.
tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(29,1): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(30,1): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(31,1): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(29,1): error TS2554: Expected 2 arguments, but got 0.
tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(30,1): error TS2554: Expected 2 arguments, but got 1.
tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(36,53): error TS2345: Argument of type '"hello"' is not assignable to parameter of type 'number'.
tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(37,12): error TS2554: Expected 1-2 arguments, but got 0.
tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(40,12): error TS2554: Expected 2 arguments, but got 1.
tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(42,53): error TS2345: Argument of type '"hello"' is not assignable to parameter of type 'number'.
tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(43,12): error TS2554: Expected 2 arguments, but got 0.
tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(47,12): error TS2554: Expected 1 arguments, but got 2.
tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(48,12): error TS2554: Expected 1 arguments, but got 2.
tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(49,12): error TS2554: Expected 1 arguments, but got 0.
tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(48,53): error TS2345: Argument of type '"hello"' is not assignable to parameter of type 'number'.
tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(49,12): error TS2554: Expected 1-2 arguments, but got 0.
tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(55,49): error TS2345: Argument of type '"hello"' is not assignable to parameter of type 'number'.
tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(56,12): error TS2555: Expected at least 1 arguments, but got 0.
tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(59,12): error TS2554: Expected 2 arguments, but got 1.
tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(61,12): error TS2554: Expected 2 arguments, but got 3.
tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(62,49): error TS2345: Argument of type '"hello"' is not assignable to parameter of type 'number'.
tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(63,12): error TS2554: Expected 2 arguments, but got 0.
tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(67,12): error TS2554: Expected 1 arguments, but got 2.
tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(68,12): error TS2554: Expected 1 arguments, but got 3.
tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(69,12): error TS2554: Expected 1 arguments, but got 2.
tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(70,12): error TS2554: Expected 1 arguments, but got 0.
tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(69,49): error TS2345: Argument of type '"hello"' is not assignable to parameter of type 'number'.
tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(70,12): error TS2555: Expected at least 1 arguments, but got 0.
==== tests/cases/conformance/types/union/unionTypeConstructSignatures.ts (30 errors) ====
==== tests/cases/conformance/types/union/unionTypeConstructSignatures.ts (26 errors) ====
var numOrDate: number | Date;
var strOrBoolean: string | boolean;
var strOrNum: string | number;
@@ -79,15 +75,15 @@ tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(70,12): erro
!!! error TS2345: Argument of type '"hello"' is not assignable to parameter of type 'number'.
var unionWithDifferentParameterCount: { new (a: string): string; } | { new (a: string, b: number): number; };
new unionWithDifferentParameterCount();// no call signature
new unionWithDifferentParameterCount();// needs more args
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
new unionWithDifferentParameterCount("hello");// no call signature
!!! error TS2554: Expected 2 arguments, but got 0.
!!! related TS6210 tests/cases/conformance/types/union/unionTypeConstructSignatures.ts:28:77: An argument for 'a' was not provided.
new unionWithDifferentParameterCount("hello");// needs more args
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
new unionWithDifferentParameterCount("hello", 10);// no call signature
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
!!! error TS2554: Expected 2 arguments, but got 1.
!!! related TS6210 tests/cases/conformance/types/union/unionTypeConstructSignatures.ts:28:88: An argument for 'b' was not provided.
new unionWithDifferentParameterCount("hello", 10);// ok
var unionWithOptionalParameter1: { new (a: string, b?: number): string; } | { new (a: string, b?: number): number; };
strOrNum = new unionWithOptionalParameter1('hello');
@@ -116,16 +112,14 @@ tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(70,12): erro
var unionWithOptionalParameter3: { new (a: string, b?: number): string; } | { new (a: string): number; };
strOrNum = new unionWithOptionalParameter3('hello'); // error no call signature
strOrNum = new unionWithOptionalParameter3('hello', 10); // error no call signature
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2554: Expected 1 arguments, but got 2.
strOrNum = new unionWithOptionalParameter3('hello', "hello"); // error no call signature
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2554: Expected 1 arguments, but got 2.
strOrNum = new unionWithOptionalParameter3('hello', 10); // ok
strOrNum = new unionWithOptionalParameter3('hello', "hello"); // wrong type
~~~~~~~
!!! error TS2345: Argument of type '"hello"' is not assignable to parameter of type 'number'.
strOrNum = new unionWithOptionalParameter3(); // error no call signature
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2554: Expected 1 arguments, but got 0.
!!! related TS6210 tests/cases/conformance/types/union/unionTypeConstructSignatures.ts:45:84: An argument for 'a' was not provided.
!!! error TS2554: Expected 1-2 arguments, but got 0.
!!! related TS6210 tests/cases/conformance/types/union/unionTypeConstructSignatures.ts:45:41: An argument for 'a' was not provided.
var unionWithRestParameter1: { new (a: string, ...b: number[]): string; } | { new (a: string, ...b: number[]): number };
strOrNum = new unionWithRestParameter1('hello');
@@ -158,16 +152,12 @@ tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(70,12): erro
var unionWithRestParameter3: { new (a: string, ...b: number[]): string; } | { new (a: string): number };
strOrNum = new unionWithRestParameter3('hello'); // error no call signature
strOrNum = new unionWithRestParameter3('hello', 10); // error no call signature
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2554: Expected 1 arguments, but got 2.
strOrNum = new unionWithRestParameter3('hello', 10, 11); // error no call signature
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2554: Expected 1 arguments, but got 3.
strOrNum = new unionWithRestParameter3('hello', "hello"); // error no call signature
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2554: Expected 1 arguments, but got 2.
strOrNum = new unionWithRestParameter3('hello', 10); // ok
strOrNum = new unionWithRestParameter3('hello', 10, 11); // ok
strOrNum = new unionWithRestParameter3('hello', "hello"); // wrong type
~~~~~~~
!!! error TS2345: Argument of type '"hello"' is not assignable to parameter of type 'number'.
strOrNum = new unionWithRestParameter3(); // error no call signature
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2554: Expected 1 arguments, but got 0.
!!! related TS6210 tests/cases/conformance/types/union/unionTypeConstructSignatures.ts:65:84: An argument for 'a' was not provided.
!!! error TS2555: Expected at least 1 arguments, but got 0.
!!! related TS6210 tests/cases/conformance/types/union/unionTypeConstructSignatures.ts:65:37: An argument for 'a' was not provided.
@@ -27,9 +27,9 @@ new unionOfDifferentNumberOfSignatures(10); // error - no call signatures
new unionOfDifferentNumberOfSignatures("hello"); // error - no call signatures
var unionWithDifferentParameterCount: { new (a: string): string; } | { new (a: string, b: number): number; };
new unionWithDifferentParameterCount();// no call signature
new unionWithDifferentParameterCount("hello");// no call signature
new unionWithDifferentParameterCount("hello", 10);// no call signature
new unionWithDifferentParameterCount();// needs more args
new unionWithDifferentParameterCount("hello");// needs more args
new unionWithDifferentParameterCount("hello", 10);// ok
var unionWithOptionalParameter1: { new (a: string, b?: number): string; } | { new (a: string, b?: number): number; };
strOrNum = new unionWithOptionalParameter1('hello');
@@ -45,8 +45,8 @@ strOrNum = new unionWithOptionalParameter2(); // error no call signature
var unionWithOptionalParameter3: { new (a: string, b?: number): string; } | { new (a: string): number; };
strOrNum = new unionWithOptionalParameter3('hello'); // error no call signature
strOrNum = new unionWithOptionalParameter3('hello', 10); // error no call signature
strOrNum = new unionWithOptionalParameter3('hello', "hello"); // error no call signature
strOrNum = new unionWithOptionalParameter3('hello', 10); // ok
strOrNum = new unionWithOptionalParameter3('hello', "hello"); // wrong type
strOrNum = new unionWithOptionalParameter3(); // error no call signature
var unionWithRestParameter1: { new (a: string, ...b: number[]): string; } | { new (a: string, ...b: number[]): number };
@@ -65,9 +65,9 @@ strOrNum = new unionWithRestParameter2(); // error no call signature
var unionWithRestParameter3: { new (a: string, ...b: number[]): string; } | { new (a: string): number };
strOrNum = new unionWithRestParameter3('hello'); // error no call signature
strOrNum = new unionWithRestParameter3('hello', 10); // error no call signature
strOrNum = new unionWithRestParameter3('hello', 10, 11); // error no call signature
strOrNum = new unionWithRestParameter3('hello', "hello"); // error no call signature
strOrNum = new unionWithRestParameter3('hello', 10); // ok
strOrNum = new unionWithRestParameter3('hello', 10, 11); // ok
strOrNum = new unionWithRestParameter3('hello', "hello"); // wrong type
strOrNum = new unionWithRestParameter3(); // error no call signature
//// [unionTypeConstructSignatures.js]
@@ -94,9 +94,9 @@ new unionOfDifferentNumberOfSignatures(); // error - no call signatures
new unionOfDifferentNumberOfSignatures(10); // error - no call signatures
new unionOfDifferentNumberOfSignatures("hello"); // error - no call signatures
var unionWithDifferentParameterCount;
new unionWithDifferentParameterCount(); // no call signature
new unionWithDifferentParameterCount("hello"); // no call signature
new unionWithDifferentParameterCount("hello", 10); // no call signature
new unionWithDifferentParameterCount(); // needs more args
new unionWithDifferentParameterCount("hello"); // needs more args
new unionWithDifferentParameterCount("hello", 10); // ok
var unionWithOptionalParameter1;
strOrNum = new unionWithOptionalParameter1('hello');
strOrNum = new unionWithOptionalParameter1('hello', 10);
@@ -109,8 +109,8 @@ strOrNum = new unionWithOptionalParameter2('hello', "hello"); // error no call s
strOrNum = new unionWithOptionalParameter2(); // error no call signature
var unionWithOptionalParameter3;
strOrNum = new unionWithOptionalParameter3('hello'); // error no call signature
strOrNum = new unionWithOptionalParameter3('hello', 10); // error no call signature
strOrNum = new unionWithOptionalParameter3('hello', "hello"); // error no call signature
strOrNum = new unionWithOptionalParameter3('hello', 10); // ok
strOrNum = new unionWithOptionalParameter3('hello', "hello"); // wrong type
strOrNum = new unionWithOptionalParameter3(); // error no call signature
var unionWithRestParameter1;
strOrNum = new unionWithRestParameter1('hello');
@@ -126,7 +126,7 @@ strOrNum = new unionWithRestParameter2('hello', "hello"); // error no call signa
strOrNum = new unionWithRestParameter2(); // error no call signature
var unionWithRestParameter3;
strOrNum = new unionWithRestParameter3('hello'); // error no call signature
strOrNum = new unionWithRestParameter3('hello', 10); // error no call signature
strOrNum = new unionWithRestParameter3('hello', 10, 11); // error no call signature
strOrNum = new unionWithRestParameter3('hello', "hello"); // error no call signature
strOrNum = new unionWithRestParameter3('hello', 10); // ok
strOrNum = new unionWithRestParameter3('hello', 10, 11); // ok
strOrNum = new unionWithRestParameter3('hello', "hello"); // wrong type
strOrNum = new unionWithRestParameter3(); // error no call signature
@@ -87,13 +87,13 @@ var unionWithDifferentParameterCount: { new (a: string): string; } | { new (a: s
>a : Symbol(a, Decl(unionTypeConstructSignatures.ts, 27, 76))
>b : Symbol(b, Decl(unionTypeConstructSignatures.ts, 27, 86))
new unionWithDifferentParameterCount();// no call signature
new unionWithDifferentParameterCount();// needs more args
>unionWithDifferentParameterCount : Symbol(unionWithDifferentParameterCount, Decl(unionTypeConstructSignatures.ts, 27, 3))
new unionWithDifferentParameterCount("hello");// no call signature
new unionWithDifferentParameterCount("hello");// needs more args
>unionWithDifferentParameterCount : Symbol(unionWithDifferentParameterCount, Decl(unionTypeConstructSignatures.ts, 27, 3))
new unionWithDifferentParameterCount("hello", 10);// no call signature
new unionWithDifferentParameterCount("hello", 10);// ok
>unionWithDifferentParameterCount : Symbol(unionWithDifferentParameterCount, Decl(unionTypeConstructSignatures.ts, 27, 3))
var unionWithOptionalParameter1: { new (a: string, b?: number): string; } | { new (a: string, b?: number): number; };
@@ -152,11 +152,11 @@ strOrNum = new unionWithOptionalParameter3('hello'); // error no call signature
>strOrNum : Symbol(strOrNum, Decl(unionTypeConstructSignatures.ts, 2, 3))
>unionWithOptionalParameter3 : Symbol(unionWithOptionalParameter3, Decl(unionTypeConstructSignatures.ts, 44, 3))
strOrNum = new unionWithOptionalParameter3('hello', 10); // error no call signature
strOrNum = new unionWithOptionalParameter3('hello', 10); // ok
>strOrNum : Symbol(strOrNum, Decl(unionTypeConstructSignatures.ts, 2, 3))
>unionWithOptionalParameter3 : Symbol(unionWithOptionalParameter3, Decl(unionTypeConstructSignatures.ts, 44, 3))
strOrNum = new unionWithOptionalParameter3('hello', "hello"); // error no call signature
strOrNum = new unionWithOptionalParameter3('hello', "hello"); // wrong type
>strOrNum : Symbol(strOrNum, Decl(unionTypeConstructSignatures.ts, 2, 3))
>unionWithOptionalParameter3 : Symbol(unionWithOptionalParameter3, Decl(unionTypeConstructSignatures.ts, 44, 3))
@@ -228,15 +228,15 @@ strOrNum = new unionWithRestParameter3('hello'); // error no call signature
>strOrNum : Symbol(strOrNum, Decl(unionTypeConstructSignatures.ts, 2, 3))
>unionWithRestParameter3 : Symbol(unionWithRestParameter3, Decl(unionTypeConstructSignatures.ts, 64, 3))
strOrNum = new unionWithRestParameter3('hello', 10); // error no call signature
strOrNum = new unionWithRestParameter3('hello', 10); // ok
>strOrNum : Symbol(strOrNum, Decl(unionTypeConstructSignatures.ts, 2, 3))
>unionWithRestParameter3 : Symbol(unionWithRestParameter3, Decl(unionTypeConstructSignatures.ts, 64, 3))
strOrNum = new unionWithRestParameter3('hello', 10, 11); // error no call signature
strOrNum = new unionWithRestParameter3('hello', 10, 11); // ok
>strOrNum : Symbol(strOrNum, Decl(unionTypeConstructSignatures.ts, 2, 3))
>unionWithRestParameter3 : Symbol(unionWithRestParameter3, Decl(unionTypeConstructSignatures.ts, 64, 3))
strOrNum = new unionWithRestParameter3('hello', "hello"); // error no call signature
strOrNum = new unionWithRestParameter3('hello', "hello"); // wrong type
>strOrNum : Symbol(strOrNum, Decl(unionTypeConstructSignatures.ts, 2, 3))
>unionWithRestParameter3 : Symbol(unionWithRestParameter3, Decl(unionTypeConstructSignatures.ts, 64, 3))
@@ -109,17 +109,17 @@ var unionWithDifferentParameterCount: { new (a: string): string; } | { new (a: s
>a : string
>b : number
new unionWithDifferentParameterCount();// no call signature
new unionWithDifferentParameterCount();// needs more args
>new unionWithDifferentParameterCount() : any
>unionWithDifferentParameterCount : (new (a: string) => string) | (new (a: string, b: number) => number)
new unionWithDifferentParameterCount("hello");// no call signature
new unionWithDifferentParameterCount("hello");// needs more args
>new unionWithDifferentParameterCount("hello") : any
>unionWithDifferentParameterCount : (new (a: string) => string) | (new (a: string, b: number) => number)
>"hello" : "hello"
new unionWithDifferentParameterCount("hello", 10);// no call signature
>new unionWithDifferentParameterCount("hello", 10) : any
new unionWithDifferentParameterCount("hello", 10);// ok
>new unionWithDifferentParameterCount("hello", 10) : string | number
>unionWithDifferentParameterCount : (new (a: string) => string) | (new (a: string, b: number) => number)
>"hello" : "hello"
>10 : 10
@@ -209,15 +209,15 @@ strOrNum = new unionWithOptionalParameter3('hello'); // error no call signature
>unionWithOptionalParameter3 : (new (a: string, b?: number) => string) | (new (a: string) => number)
>'hello' : "hello"
strOrNum = new unionWithOptionalParameter3('hello', 10); // error no call signature
>strOrNum = new unionWithOptionalParameter3('hello', 10) : any
strOrNum = new unionWithOptionalParameter3('hello', 10); // ok
>strOrNum = new unionWithOptionalParameter3('hello', 10) : string | number
>strOrNum : string | number
>new unionWithOptionalParameter3('hello', 10) : any
>new unionWithOptionalParameter3('hello', 10) : string | number
>unionWithOptionalParameter3 : (new (a: string, b?: number) => string) | (new (a: string) => number)
>'hello' : "hello"
>10 : 10
strOrNum = new unionWithOptionalParameter3('hello', "hello"); // error no call signature
strOrNum = new unionWithOptionalParameter3('hello', "hello"); // wrong type
>strOrNum = new unionWithOptionalParameter3('hello', "hello") : any
>strOrNum : string | number
>new unionWithOptionalParameter3('hello', "hello") : any
@@ -334,24 +334,24 @@ strOrNum = new unionWithRestParameter3('hello'); // error no call signature
>unionWithRestParameter3 : (new (a: string, ...b: number[]) => string) | (new (a: string) => number)
>'hello' : "hello"
strOrNum = new unionWithRestParameter3('hello', 10); // error no call signature
>strOrNum = new unionWithRestParameter3('hello', 10) : any
strOrNum = new unionWithRestParameter3('hello', 10); // ok
>strOrNum = new unionWithRestParameter3('hello', 10) : string | number
>strOrNum : string | number
>new unionWithRestParameter3('hello', 10) : any
>new unionWithRestParameter3('hello', 10) : string | number
>unionWithRestParameter3 : (new (a: string, ...b: number[]) => string) | (new (a: string) => number)
>'hello' : "hello"
>10 : 10
strOrNum = new unionWithRestParameter3('hello', 10, 11); // error no call signature
>strOrNum = new unionWithRestParameter3('hello', 10, 11) : any
strOrNum = new unionWithRestParameter3('hello', 10, 11); // ok
>strOrNum = new unionWithRestParameter3('hello', 10, 11) : string | number
>strOrNum : string | number
>new unionWithRestParameter3('hello', 10, 11) : any
>new unionWithRestParameter3('hello', 10, 11) : string | number
>unionWithRestParameter3 : (new (a: string, ...b: number[]) => string) | (new (a: string) => number)
>'hello' : "hello"
>10 : 10
>11 : 11
strOrNum = new unionWithRestParameter3('hello', "hello"); // error no call signature
strOrNum = new unionWithRestParameter3('hello', "hello"); // wrong type
>strOrNum = new unionWithRestParameter3('hello', "hello") : any
>strOrNum : string | number
>new unionWithRestParameter3('hello', "hello") : any
@@ -0,0 +1,25 @@
// @jsx: react
/// <reference path="/.lib/react16.d.ts" />
import * as React from 'react';
declare const Radio: (props: {}) => React.ReactElement<{}>;
declare const OtherRadio: () => React.ReactElement<{}>;
declare const Checkbox: React.SFC;
declare const condition1: boolean;
declare const condition2: boolean;
declare const condition3: boolean;
const RandomComponent: React.SFC = () => {
const Component =
condition1
? Radio
: Checkbox;
const OtherComponent =
condition2
? OtherRadio
: Checkbox;
return condition1 ? <Component /> : <OtherComponent />;
};
@@ -26,9 +26,9 @@ unionOfDifferentNumberOfSignatures(10); // error - no call signatures
unionOfDifferentNumberOfSignatures("hello"); // error - no call signatures
var unionWithDifferentParameterCount: { (a: string): string; } | { (a: string, b: number): number; } ;
unionWithDifferentParameterCount();// no call signature
unionWithDifferentParameterCount("hello");// no call signature
unionWithDifferentParameterCount("hello", 10);// no call signature
unionWithDifferentParameterCount();// needs more args
unionWithDifferentParameterCount("hello");// needs more args
unionWithDifferentParameterCount("hello", 10);// OK
var unionWithOptionalParameter1: { (a: string, b?: number): string; } | { (a: string, b?: number): number; };
strOrNum = unionWithOptionalParameter1('hello');
@@ -44,9 +44,9 @@ strOrNum = unionWithOptionalParameter2(); // error no call signature
var unionWithOptionalParameter3: { (a: string, b?: number): string; } | { (a: string): number; };
strOrNum = unionWithOptionalParameter3('hello');
strOrNum = unionWithOptionalParameter3('hello', 10); // error no call signature
strOrNum = unionWithOptionalParameter3('hello', "hello"); // error no call signature
strOrNum = unionWithOptionalParameter3(); // error no call signature
strOrNum = unionWithOptionalParameter3('hello', 10); // ok
strOrNum = unionWithOptionalParameter3('hello', "hello"); // wrong argument type
strOrNum = unionWithOptionalParameter3(); // needs more args
var unionWithRestParameter1: { (a: string, ...b: number[]): string; } | { (a: string, ...b: number[]): number };
strOrNum = unionWithRestParameter1('hello');
@@ -66,7 +66,7 @@ var unionWithRestParameter3: { (a: string, ...b: number[]): string; } | { (a: st
strOrNum = unionWithRestParameter3('hello');
strOrNum = unionWithRestParameter3('hello', 10); // error no call signature
strOrNum = unionWithRestParameter3('hello', 10, 11); // error no call signature
strOrNum = unionWithRestParameter3('hello', "hello"); // error no call signature
strOrNum = unionWithRestParameter3('hello', "hello"); // wrong argument type
strOrNum = unionWithRestParameter3(); // error no call signature
var unionWithRestParameter4: { (...a: string[]): string; } | { (a: string, b: string): number; };
@@ -7,7 +7,7 @@ type F5 = (a: string, b: string) => void;
var f12: F1 | F2;
f12("a");
f12("a", "b");
f12("a", "b", "c"); // error
f12("a", "b", "c"); // ok
var f34: F3 | F4;
f34("a");
@@ -17,7 +17,7 @@ f34("a", "b", "c");
var f1234: F1 | F2 | F3 | F4;
f1234("a");
f1234("a", "b");
f1234("a", "b", "c"); // error
f1234("a", "b", "c"); // ok
var f12345: F1 | F2 | F3 | F4 | F5;
f12345("a"); // error
@@ -26,9 +26,9 @@ new unionOfDifferentNumberOfSignatures(10); // error - no call signatures
new unionOfDifferentNumberOfSignatures("hello"); // error - no call signatures
var unionWithDifferentParameterCount: { new (a: string): string; } | { new (a: string, b: number): number; };
new unionWithDifferentParameterCount();// no call signature
new unionWithDifferentParameterCount("hello");// no call signature
new unionWithDifferentParameterCount("hello", 10);// no call signature
new unionWithDifferentParameterCount();// needs more args
new unionWithDifferentParameterCount("hello");// needs more args
new unionWithDifferentParameterCount("hello", 10);// ok
var unionWithOptionalParameter1: { new (a: string, b?: number): string; } | { new (a: string, b?: number): number; };
strOrNum = new unionWithOptionalParameter1('hello');
@@ -44,8 +44,8 @@ strOrNum = new unionWithOptionalParameter2(); // error no call signature
var unionWithOptionalParameter3: { new (a: string, b?: number): string; } | { new (a: string): number; };
strOrNum = new unionWithOptionalParameter3('hello'); // error no call signature
strOrNum = new unionWithOptionalParameter3('hello', 10); // error no call signature
strOrNum = new unionWithOptionalParameter3('hello', "hello"); // error no call signature
strOrNum = new unionWithOptionalParameter3('hello', 10); // ok
strOrNum = new unionWithOptionalParameter3('hello', "hello"); // wrong type
strOrNum = new unionWithOptionalParameter3(); // error no call signature
var unionWithRestParameter1: { new (a: string, ...b: number[]): string; } | { new (a: string, ...b: number[]): number };
@@ -64,7 +64,7 @@ strOrNum = new unionWithRestParameter2(); // error no call signature
var unionWithRestParameter3: { new (a: string, ...b: number[]): string; } | { new (a: string): number };
strOrNum = new unionWithRestParameter3('hello'); // error no call signature
strOrNum = new unionWithRestParameter3('hello', 10); // error no call signature
strOrNum = new unionWithRestParameter3('hello', 10, 11); // error no call signature
strOrNum = new unionWithRestParameter3('hello', "hello"); // error no call signature
strOrNum = new unionWithRestParameter3('hello', 10); // ok
strOrNum = new unionWithRestParameter3('hello', 10, 11); // ok
strOrNum = new unionWithRestParameter3('hello', "hello"); // wrong type
strOrNum = new unionWithRestParameter3(); // error no call signature
@@ -17,7 +17,7 @@
verify.completions({
marker: "",
exact: [
{ name: "toString", text: "(method) toString(): string", documentation: "Returns a string representation of a string.", },
{ name: "toString", text: "(method) toString(): string (+1 overload)", documentation: "Returns a string representation of a string.", },
{ name: "valueOf", text: "(method) valueOf(): string | number", documentation: "Returns the primitive value of the specified object." },
],
});