TypeScript 3.4
顶级 this 现在有类型了
this 现在有类型了// 在 `noImplicitAny` 下,以前可以,现在不行
this.whargarbl = 10;泛型参数的传递
declare function compose<T, U, V>(f: (arg: T) => U, g: (arg: U) => V): (arg: T) => V;
function list<T>(x: T) { return [x]; }
function box<T>(value: T) { return { value }; }
let f = compose(list, box);
let x = f(100)
// 在 TypeScript 3.4 中, 'x.value' 的类型为
//
// number[]
//
// 但是在之前的版本中类型为
//
// {}[]
//
// 因此,插入一个 `string` 类型是错误的
x.value.push("hello");上下文返回类型作为上下文参数类型传入
在 strictFunctionTypes 之外一致性推断优先
strictFunctionTypes 之外一致性推断优先参考
Last updated