15. OmitThisParameter<T> を実装する
シェアしよう
- accepted / - tried
Function.prototype.bind()
を使うと、this
は固定される。
こういうケースのため、OmitThisParameter<T>
を使うと良い。
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