Domain: enumHelp WantedPossible Improvement
Métricas do repositório
- Stars
- (48.455 stars)
- Métricas de merge de PR
- (Mesclagem média 6d 17h) (9 fundiu PRs em 30d)
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 https://github.com/microsoft/TypeScript/issues/48363 . As such it relates to the open https://github.com/microsoft/TypeScript/issues/59754 too