-
Notifications
You must be signed in to change notification settings - Fork 13k
Open
Labels
Help WantedYou can do thisYou can do thisPossible ImprovementThe current behavior isn't wrong, but it's possible to see that it might be better in some casesThe current behavior isn't wrong, but it's possible to see that it might be better in some cases
Milestone
Description
π Search Terms
return type inference enum union literal fresh regular
π Version & Regression Information
- This is the behavior in every version I tried
β― Playground Link
π» Code
enum E { A, B }
type Box<T> = {
get: () => T;
set: (value: T) => void;
};
declare function box<T>(value: T): Box<T>;
const bn1 = box(0); // Box<number>
const bn2: Box<number> = box(0); // Ok
const be1 = box(E.A); // Box<E>
const be2: Box<E> = box(E.A); // Error, box<E.A> not assignable to Box<E>
π Actual behavior
be2
errors
π Expected behavior
be2
shouldn't error
Additional information about the issue
This is an enum-based variant of #48363 . As such it relates to the open #59754 too
Metadata
Metadata
Assignees
Labels
Help WantedYou can do thisYou can do thisPossible ImprovementThe current behavior isn't wrong, but it's possible to see that it might be better in some casesThe current behavior isn't wrong, but it's possible to see that it might be better in some cases