Accept new baselines

This commit is contained in:
Anders Hejlsberg 2017-12-01 16:54:40 -08:00
parent 3531bd2b57
commit 35188c5093
4 changed files with 196 additions and 0 deletions

View file

@ -0,0 +1,35 @@
tests/cases/compiler/functionCallOnConstrainedTypeVariable.ts(11,3): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((x: number) => string) | ((x: boolean) => string)' has no compatible call signatures.
tests/cases/compiler/functionCallOnConstrainedTypeVariable.ts(15,3): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((x: number) => string) | ((x: boolean) => string)' has no compatible call signatures.
tests/cases/compiler/functionCallOnConstrainedTypeVariable.ts(18,3): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((x: number) => string) | ((x: boolean) => string)' has no compatible call signatures.
tests/cases/compiler/functionCallOnConstrainedTypeVariable.ts(19,3): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((x: number) => string) | ((x: boolean) => string)' has no compatible call signatures.
==== tests/cases/compiler/functionCallOnConstrainedTypeVariable.ts (4 errors) ====
// Repro from #20196
type A = {
a: (x: number) => string
};
type B = {
a: (x: boolean) => string
};
function call0(p: A | B) {
p.a("s"); // Error
~~~~~~~~
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((x: number) => string) | ((x: boolean) => string)' has no compatible call signatures.
}
function callN<T extends A | B>(p: T) {
p.a("s"); // Error
~~~~~~~~
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((x: number) => string) | ((x: boolean) => string)' has no compatible call signatures.
var a: T["a"] = p.a;
a(""); // Error
~~~~~
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((x: number) => string) | ((x: boolean) => string)' has no compatible call signatures.
a("", "", "", ""); // Error
~~~~~~~~~~~~~~~~~
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((x: number) => string) | ((x: boolean) => string)' has no compatible call signatures.
}

View file

@ -0,0 +1,34 @@
//// [functionCallOnConstrainedTypeVariable.ts]
// Repro from #20196
type A = {
a: (x: number) => string
};
type B = {
a: (x: boolean) => string
};
function call0(p: A | B) {
p.a("s"); // Error
}
function callN<T extends A | B>(p: T) {
p.a("s"); // Error
var a: T["a"] = p.a;
a(""); // Error
a("", "", "", ""); // Error
}
//// [functionCallOnConstrainedTypeVariable.js]
"use strict";
// Repro from #20196
function call0(p) {
p.a("s"); // Error
}
function callN(p) {
p.a("s"); // Error
var a = p.a;
a(""); // Error
a("", "", "", ""); // Error
}

View file

@ -0,0 +1,58 @@
=== tests/cases/compiler/functionCallOnConstrainedTypeVariable.ts ===
// Repro from #20196
type A = {
>A : Symbol(A, Decl(functionCallOnConstrainedTypeVariable.ts, 0, 0))
a: (x: number) => string
>a : Symbol(a, Decl(functionCallOnConstrainedTypeVariable.ts, 2, 10))
>x : Symbol(x, Decl(functionCallOnConstrainedTypeVariable.ts, 3, 6))
};
type B = {
>B : Symbol(B, Decl(functionCallOnConstrainedTypeVariable.ts, 4, 2))
a: (x: boolean) => string
>a : Symbol(a, Decl(functionCallOnConstrainedTypeVariable.ts, 5, 10))
>x : Symbol(x, Decl(functionCallOnConstrainedTypeVariable.ts, 6, 6))
};
function call0(p: A | B) {
>call0 : Symbol(call0, Decl(functionCallOnConstrainedTypeVariable.ts, 7, 2))
>p : Symbol(p, Decl(functionCallOnConstrainedTypeVariable.ts, 9, 15))
>A : Symbol(A, Decl(functionCallOnConstrainedTypeVariable.ts, 0, 0))
>B : Symbol(B, Decl(functionCallOnConstrainedTypeVariable.ts, 4, 2))
p.a("s"); // Error
>p.a : Symbol(a, Decl(functionCallOnConstrainedTypeVariable.ts, 2, 10), Decl(functionCallOnConstrainedTypeVariable.ts, 5, 10))
>p : Symbol(p, Decl(functionCallOnConstrainedTypeVariable.ts, 9, 15))
>a : Symbol(a, Decl(functionCallOnConstrainedTypeVariable.ts, 2, 10), Decl(functionCallOnConstrainedTypeVariable.ts, 5, 10))
}
function callN<T extends A | B>(p: T) {
>callN : Symbol(callN, Decl(functionCallOnConstrainedTypeVariable.ts, 11, 1))
>T : Symbol(T, Decl(functionCallOnConstrainedTypeVariable.ts, 13, 15))
>A : Symbol(A, Decl(functionCallOnConstrainedTypeVariable.ts, 0, 0))
>B : Symbol(B, Decl(functionCallOnConstrainedTypeVariable.ts, 4, 2))
>p : Symbol(p, Decl(functionCallOnConstrainedTypeVariable.ts, 13, 32))
>T : Symbol(T, Decl(functionCallOnConstrainedTypeVariable.ts, 13, 15))
p.a("s"); // Error
>p.a : Symbol(a, Decl(functionCallOnConstrainedTypeVariable.ts, 2, 10), Decl(functionCallOnConstrainedTypeVariable.ts, 5, 10))
>p : Symbol(p, Decl(functionCallOnConstrainedTypeVariable.ts, 13, 32))
>a : Symbol(a, Decl(functionCallOnConstrainedTypeVariable.ts, 2, 10), Decl(functionCallOnConstrainedTypeVariable.ts, 5, 10))
var a: T["a"] = p.a;
>a : Symbol(a, Decl(functionCallOnConstrainedTypeVariable.ts, 16, 5))
>T : Symbol(T, Decl(functionCallOnConstrainedTypeVariable.ts, 13, 15))
>p.a : Symbol(a, Decl(functionCallOnConstrainedTypeVariable.ts, 2, 10), Decl(functionCallOnConstrainedTypeVariable.ts, 5, 10))
>p : Symbol(p, Decl(functionCallOnConstrainedTypeVariable.ts, 13, 32))
>a : Symbol(a, Decl(functionCallOnConstrainedTypeVariable.ts, 2, 10), Decl(functionCallOnConstrainedTypeVariable.ts, 5, 10))
a(""); // Error
>a : Symbol(a, Decl(functionCallOnConstrainedTypeVariable.ts, 16, 5))
a("", "", "", ""); // Error
>a : Symbol(a, Decl(functionCallOnConstrainedTypeVariable.ts, 16, 5))
}

View file

@ -0,0 +1,69 @@
=== tests/cases/compiler/functionCallOnConstrainedTypeVariable.ts ===
// Repro from #20196
type A = {
>A : A
a: (x: number) => string
>a : (x: number) => string
>x : number
};
type B = {
>B : B
a: (x: boolean) => string
>a : (x: boolean) => string
>x : boolean
};
function call0(p: A | B) {
>call0 : (p: A | B) => void
>p : A | B
>A : A
>B : B
p.a("s"); // Error
>p.a("s") : any
>p.a : ((x: number) => string) | ((x: boolean) => string)
>p : A | B
>a : ((x: number) => string) | ((x: boolean) => string)
>"s" : "s"
}
function callN<T extends A | B>(p: T) {
>callN : <T extends A | B>(p: T) => void
>T : T
>A : A
>B : B
>p : T
>T : T
p.a("s"); // Error
>p.a("s") : any
>p.a : ((x: number) => string) | ((x: boolean) => string)
>p : T
>a : ((x: number) => string) | ((x: boolean) => string)
>"s" : "s"
var a: T["a"] = p.a;
>a : T["a"]
>T : T
>p.a : ((x: number) => string) | ((x: boolean) => string)
>p : T
>a : ((x: number) => string) | ((x: boolean) => string)
a(""); // Error
>a("") : any
>a : T["a"]
>"" : ""
a("", "", "", ""); // Error
>a("", "", "", "") : any
>a : T["a"]
>"" : ""
>"" : ""
>"" : ""
>"" : ""
}