Closed
Description
Bug Report
π Search Terms
ThisType
π Version & Regression Information
- This is a crash
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about
ThisType
β― Playground Link
Playground link with relevant code
π» Code
function defineComp<Bar, Data>(
options: {
bar: Bar,
foo: () => Data
} & ThisType<{ bar: Bar }>
): Bar
function defineComp(options: any) {
return options.bar
}
// failed
const aaa = defineComp({
foo() {
console.log(this.bar) // no error
return {
count: this.bar() // throw error
}
},
bar() {
return '1'
},
})
// work
const bbb = defineComp({
bar() {
return '1'
},
foo() {
console.log(this.bar)
return {
count: this.bar() // it's work
}
},
})
π Actual behavior
TS error: (property) bar: unknown
in aaa
π Expected behavior
no error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment