Microsoft/TypeScript
Auf GitHub ansehenWeak type not rejected when intersected with `ThisType`
Open
#56.995 geöffnet am 9. Jan. 2024
BugDomain: This-TypingHelp Wanted
Repository-Metriken
- Stars
- (48.455 Stars)
- PR-Merge-Metriken
- (Durchschn. Merge 6T 17h) (9 gemergte PRs in 30 T)
Beschreibung
🔎 Search Terms
- function overload
- ThisType
- this
🕗 Version & Regression Information
- This is a crash
⏯ Playground Link
💻 Code
interface Foo {
a: string
}
declare function fun0(arg: () => (
& Foo
& ThisType<Foo>
)): void
declare function fun0(arg: (
& Partial<Foo>
& ThisType<Foo>
)): void
fun0({
// ^? function fun0(arg: (Partial<Foo> & ThisType<Foo>)): void (+1 overload)
a: '1'
})
fun0(() => ({
// ^? function fun0(arg: () => (Foo & ThisType<Foo>)): void (+1 overload)
a: '1'
}))
// @ts-expect-error
fun0(() => ({
// ^? function fun0(arg: (Partial<Foo> & ThisType<Foo>)): void (+1 overload)
a: 1
}))
When I intersect ThisType with a type similar to {} and use it as a function argument, it will always resolve to this declaration.
🙁 Actual behavior
overload to function fun0(arg: (Partial<Foo> & ThisType<Foo>)): void (+1 overload)
🙂 Expected behavior
overload to function fun0(arg: () => (Partial<Foo> & ThisType<Foo>)): void (+1 overload)
Additional information about the issue
When I comment ThisType intesection, it works.