Addressing CR feedback
This commit is contained in:
parent
c00ee42b11
commit
e5872b4824
|
@ -3,24 +3,30 @@
|
|||
// If e is an expression of a function type that contains exactly one generic call signature and no other members,
|
||||
// and T is a function type with exactly one non - generic call signature and no other members, then any inferences
|
||||
// made for type parameters referenced by the parameters of T's call signature are fixed, and e's type is changed
|
||||
// to a function type with e's call signature instantiated in the context of T<EFBFBD>s call signature (section 3.8.5).
|
||||
// to a function type with e's call signature instantiated in the context of T's call signature (section 3.8.5).
|
||||
|
||||
declare function foo<T>(cb: (x: number, y: string) => T): T;
|
||||
declare function bar<T, U, V>(x: T, y: U, cb: (x: T, y: U) => V): V;
|
||||
declare function baz<T, U>(x: T, y: T, cb: (x: T, y: T) => U): U;
|
||||
|
||||
declare function f(x: number, y: string): boolean;
|
||||
declare function g<T>(x: T, y: T): T;
|
||||
declare function h<T, U>(x: T, y: U): T[] | U[];
|
||||
|
||||
var a: boolean;
|
||||
var a = foo(f); // Should be boolean
|
||||
var a: number;
|
||||
var a = bar(1, 1, g); // Should be number
|
||||
var a = baz(1, 1, g); // Should be number
|
||||
|
||||
var b: number | string;
|
||||
var b = foo(g); // Should be number | string
|
||||
var b = bar(1, "one", g); // Should be number | string
|
||||
var b = bar("one", 1, g); // Should be number | string
|
||||
var b = baz(b, b, g); // Should be number | string
|
||||
|
||||
var c: number;
|
||||
var c = bar(1, 1, g); // Should be number
|
||||
var d: number[] | string[];
|
||||
var d = foo(h); // Should be number[] | string[]
|
||||
var d = bar(1, "one", h); // Should be number[] | string[]
|
||||
var d = bar("one", 1, h); // Should be number[] | string[]
|
||||
var d = baz(d, d, g); // Should be number[] | string[]
|
||||
|
||||
|
||||
//// [contextualSignatureInstantiation.js]
|
||||
|
@ -28,12 +34,17 @@ var c = bar(1, 1, g); // Should be number
|
|||
// If e is an expression of a function type that contains exactly one generic call signature and no other members,
|
||||
// and T is a function type with exactly one non - generic call signature and no other members, then any inferences
|
||||
// made for type parameters referenced by the parameters of T's call signature are fixed, and e's type is changed
|
||||
// to a function type with e's call signature instantiated in the context of T<EFBFBD>s call signature (section 3.8.5).
|
||||
// to a function type with e's call signature instantiated in the context of T's call signature (section 3.8.5).
|
||||
var a;
|
||||
var a = foo(f); // Should be boolean
|
||||
var a = bar(1, 1, g); // Should be number
|
||||
var a = baz(1, 1, g); // Should be number
|
||||
var b;
|
||||
var b = foo(g); // Should be number | string
|
||||
var b = bar(1, "one", g); // Should be number | string
|
||||
var b = bar("one", 1, g); // Should be number | string
|
||||
var c;
|
||||
var c = bar(1, 1, g); // Should be number
|
||||
var b = baz(b, b, g); // Should be number | string
|
||||
var d;
|
||||
var d = foo(h); // Should be number[] | string[]
|
||||
var d = bar(1, "one", h); // Should be number[] | string[]
|
||||
var d = bar("one", 1, h); // Should be number[] | string[]
|
||||
var d = baz(d, d, g); // Should be number[] | string[]
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
// If e is an expression of a function type that contains exactly one generic call signature and no other members,
|
||||
// and T is a function type with exactly one non - generic call signature and no other members, then any inferences
|
||||
// made for type parameters referenced by the parameters of T's call signature are fixed, and e's type is changed
|
||||
// to a function type with e's call signature instantiated in the context of T<EFBFBD>s call signature (section 3.8.5).
|
||||
// to a function type with e's call signature instantiated in the context of T's call signature (section 3.8.5).
|
||||
|
||||
declare function foo<T>(cb: (x: number, y: string) => T): T;
|
||||
>foo : <T>(cb: (x: number, y: string) => T) => T
|
||||
|
@ -31,10 +31,21 @@ declare function bar<T, U, V>(x: T, y: U, cb: (x: T, y: U) => V): V;
|
|||
>V : V
|
||||
>V : V
|
||||
|
||||
declare function f(x: number, y: string): boolean;
|
||||
>f : (x: number, y: string) => boolean
|
||||
>x : number
|
||||
>y : string
|
||||
declare function baz<T, U>(x: T, y: T, cb: (x: T, y: T) => U): U;
|
||||
>baz : <T, U>(x: T, y: T, cb: (x: T, y: T) => U) => U
|
||||
>T : T
|
||||
>U : U
|
||||
>x : T
|
||||
>T : T
|
||||
>y : T
|
||||
>T : T
|
||||
>cb : (x: T, y: T) => U
|
||||
>x : T
|
||||
>T : T
|
||||
>y : T
|
||||
>T : T
|
||||
>U : U
|
||||
>U : U
|
||||
|
||||
declare function g<T>(x: T, y: T): T;
|
||||
>g : <T>(x: T, y: T) => T
|
||||
|
@ -45,14 +56,31 @@ declare function g<T>(x: T, y: T): T;
|
|||
>T : T
|
||||
>T : T
|
||||
|
||||
var a: boolean;
|
||||
>a : boolean
|
||||
declare function h<T, U>(x: T, y: U): T[] | U[];
|
||||
>h : <T, U>(x: T, y: U) => T[] | U[]
|
||||
>T : T
|
||||
>U : U
|
||||
>x : T
|
||||
>T : T
|
||||
>y : U
|
||||
>U : U
|
||||
>T : T
|
||||
>U : U
|
||||
|
||||
var a = foo(f); // Should be boolean
|
||||
>a : boolean
|
||||
>foo(f) : boolean
|
||||
>foo : <T>(cb: (x: number, y: string) => T) => T
|
||||
>f : (x: number, y: string) => boolean
|
||||
var a: number;
|
||||
>a : number
|
||||
|
||||
var a = bar(1, 1, g); // Should be number
|
||||
>a : number
|
||||
>bar(1, 1, g) : number
|
||||
>bar : <T, U, V>(x: T, y: U, cb: (x: T, y: U) => V) => V
|
||||
>g : <T>(x: T, y: T) => T
|
||||
|
||||
var a = baz(1, 1, g); // Should be number
|
||||
>a : number
|
||||
>baz(1, 1, g) : number
|
||||
>baz : <T, U>(x: T, y: T, cb: (x: T, y: T) => U) => U
|
||||
>g : <T>(x: T, y: T) => T
|
||||
|
||||
var b: number | string;
|
||||
>b : string | number
|
||||
|
@ -75,12 +103,40 @@ var b = bar("one", 1, g); // Should be number | string
|
|||
>bar : <T, U, V>(x: T, y: U, cb: (x: T, y: U) => V) => V
|
||||
>g : <T>(x: T, y: T) => T
|
||||
|
||||
var c: number;
|
||||
>c : number
|
||||
|
||||
var c = bar(1, 1, g); // Should be number
|
||||
>c : number
|
||||
>bar(1, 1, g) : number
|
||||
>bar : <T, U, V>(x: T, y: U, cb: (x: T, y: U) => V) => V
|
||||
var b = baz(b, b, g); // Should be number | string
|
||||
>b : string | number
|
||||
>baz(b, b, g) : string | number
|
||||
>baz : <T, U>(x: T, y: T, cb: (x: T, y: T) => U) => U
|
||||
>b : string | number
|
||||
>b : string | number
|
||||
>g : <T>(x: T, y: T) => T
|
||||
|
||||
var d: number[] | string[];
|
||||
>d : string[] | number[]
|
||||
|
||||
var d = foo(h); // Should be number[] | string[]
|
||||
>d : string[] | number[]
|
||||
>foo(h) : string[] | number[]
|
||||
>foo : <T>(cb: (x: number, y: string) => T) => T
|
||||
>h : <T, U>(x: T, y: U) => T[] | U[]
|
||||
|
||||
var d = bar(1, "one", h); // Should be number[] | string[]
|
||||
>d : string[] | number[]
|
||||
>bar(1, "one", h) : string[] | number[]
|
||||
>bar : <T, U, V>(x: T, y: U, cb: (x: T, y: U) => V) => V
|
||||
>h : <T, U>(x: T, y: U) => T[] | U[]
|
||||
|
||||
var d = bar("one", 1, h); // Should be number[] | string[]
|
||||
>d : string[] | number[]
|
||||
>bar("one", 1, h) : string[] | number[]
|
||||
>bar : <T, U, V>(x: T, y: U, cb: (x: T, y: U) => V) => V
|
||||
>h : <T, U>(x: T, y: U) => T[] | U[]
|
||||
|
||||
var d = baz(d, d, g); // Should be number[] | string[]
|
||||
>d : string[] | number[]
|
||||
>baz(d, d, g) : string[] | number[]
|
||||
>baz : <T, U>(x: T, y: T, cb: (x: T, y: T) => U) => U
|
||||
>d : string[] | number[]
|
||||
>d : string[] | number[]
|
||||
>g : <T>(x: T, y: T) => T
|
||||
|
||||
|
|
|
@ -2,21 +2,27 @@
|
|||
// If e is an expression of a function type that contains exactly one generic call signature and no other members,
|
||||
// and T is a function type with exactly one non - generic call signature and no other members, then any inferences
|
||||
// made for type parameters referenced by the parameters of T's call signature are fixed, and e's type is changed
|
||||
// to a function type with e's call signature instantiated in the context of T’s call signature (section 3.8.5).
|
||||
// to a function type with e's call signature instantiated in the context of T's call signature (section 3.8.5).
|
||||
|
||||
declare function foo<T>(cb: (x: number, y: string) => T): T;
|
||||
declare function bar<T, U, V>(x: T, y: U, cb: (x: T, y: U) => V): V;
|
||||
declare function baz<T, U>(x: T, y: T, cb: (x: T, y: T) => U): U;
|
||||
|
||||
declare function f(x: number, y: string): boolean;
|
||||
declare function g<T>(x: T, y: T): T;
|
||||
declare function h<T, U>(x: T, y: U): T[] | U[];
|
||||
|
||||
var a: boolean;
|
||||
var a = foo(f); // Should be boolean
|
||||
var a: number;
|
||||
var a = bar(1, 1, g); // Should be number
|
||||
var a = baz(1, 1, g); // Should be number
|
||||
|
||||
var b: number | string;
|
||||
var b = foo(g); // Should be number | string
|
||||
var b = bar(1, "one", g); // Should be number | string
|
||||
var b = bar("one", 1, g); // Should be number | string
|
||||
var b = baz(b, b, g); // Should be number | string
|
||||
|
||||
var c: number;
|
||||
var c = bar(1, 1, g); // Should be number
|
||||
var d: number[] | string[];
|
||||
var d = foo(h); // Should be number[] | string[]
|
||||
var d = bar(1, "one", h); // Should be number[] | string[]
|
||||
var d = bar("one", 1, h); // Should be number[] | string[]
|
||||
var d = baz(d, d, g); // Should be number[] | string[]
|
||||
|
|
Loading…
Reference in a new issue