BugDomain: Mapped TypesHelp Wanted
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
optional mapped type
🕗 Version & Regression Information
- This changed between versions 5.4.5 and 5.5.4
⏯ Playground Link
💻 Code
type OptionalToUnionWithUndefined<T> = {
[K in keyof T]: T extends Record<K, T[K]>
? T[K]
: T[K] | undefined
}
type Intermediate = OptionalToUnionWithUndefined<{ a?: string }> // { a?: string | undefined }
type Literal = { a?: string | undefined } // same type as Intermediate
type Res1 = Required<Intermediate> // { a: string }
type Res2 = Required<Literal> // { a: string | undefined }
🙁 Actual behavior
Res1 and Res2 are different types
🙂 Expected behavior
they should be the same because the inputs are
Additional information about the issue
This issue may share the cause with #59902