15. 实现OmitThisParameter<T>
分享给更多人
-通过 / -执行
Function.prototype.bind()
返回一个this
已经bind过后的function。
对于这种情况,可以用OmitThisParameter<T>
来增加type信息。
请自行实现MyOmitThisParameter<T>
。
function foo(this: {a: string}) {}
foo() // Error
const bar = foo.bind({a: 'BFE.dev'})
bar() // OK
type Foo = (this: {a: string}) => string
type Bar = MyOmitThisParameter<Foo> // () => string