-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Labels
Typing: completenessNo false positives (type checker claims that there are some errors in the correct program)No false positives (type checker claims that there are some errors in the correct program)bug
Description
Flow version: 0.278.0
Expected behavior
function fn<T: string>(str: T): void {
str as (T extends string ? T : T); // works
str as (T extends number ? T : T); // should work but errors
}
Actual behavior
3: str as (T extends number ? T : T); // should work but errors
^ Cannot cast `str` to conditional type because string [1] is incompatible with conditional type [2]. [incompatible-cast]
References:
1: function fn<T: string>(str: T): void {
^ [1]
3: str as (T extends number ? T : T); // should work but errors
^ [2]
I understand this is a very contrived example, but I was trying to come up with a minimal reproduction that demonstrates the issue clearly. We've hit this in real code, and I used something closer to a real example in the Try-Flow below.
- Link to Try-Flow or Github repo: Try-Flow
Metadata
Metadata
Assignees
Labels
Typing: completenessNo false positives (type checker claims that there are some errors in the correct program)No false positives (type checker claims that there are some errors in the correct program)bug