-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Open
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: check: Type InferenceRelated to type inference performed during signature resolution or `infer` type resolutionRelated to type inference performed during signature resolution or `infer` type resolution
Milestone
Description
Acknowledgement
I have asked the question on Gitter and most of the users believe it's a bug and I have search for existing issues and didn't found any.
Issue
Let's start with the code. Playground link
declare class Foo {
public red(): this
public red(text: string): string
}
declare class Bar {
public red(): this
public red(text: string): string
}
const foo: Foo | Bar = new Foo()
const a = foo.red('text')In the above code, I expect the variable a to be a string. However, it is string | Bar.
Now, things get even weird when I replace string with object in the return types of red method.
declare class Foo {
public red(): this
public red(text: string): object
}
declare class Bar {
public red(): this
public red(text: string): object
}
const foo: Foo | Bar = new Foo()
const a = foo.red('text')Now suddenly, a is an object (which is correct)
AnyhowStep
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: check: Type InferenceRelated to type inference performed during signature resolution or `infer` type resolutionRelated to type inference performed during signature resolution or `infer` type resolution