Skip to content

PickDeep does not pick types unioned to object or arrays #1224

@Wendystraite

Description

@Wendystraite

Bug description

PickDeep does not pick types unioned to object or arrays.

The bug in code (playground) :

// actual   : type FooObj = { obj: { b: number } & { c: boolean } }
// expected : type FooObj = { obj: string | { b: number; c: boolean } | null | undefined }
type FooObj = PickDeep<
  { obj: string | { a: string; b: number; c: boolean } | null | undefined },
  `obj.${'b' | 'c'}`
>;

.. and you can't pick these values by PickDeep<..., 'obj' | 'obj.b'> or your resulting type contain the full object defeating the purpose of the type.

Repro

https://www.typescriptlang.org/play/#code/JYWwDg9gTgLgBDAnmApnA3nACsAxgawBEUUw4BfOAMyghDgHIlUBaKlAZxgYG4BYAFCDmaQgEMYYuAF4MguArgQARgCsAXHC5RgAOwDmcAD4Y4Yzdr36ecZZt0BXEMpRQbuTcogQANijG6FMZwjj4+wQ66ACYoVHooUfwCimZQUJqY5lowOgY2diFOLm5wHrbefgEK5ADaALoR0bHxiYLkSYIA9ABUgmK4MA5i4erCyGgAYt4A8moycsmKKhoLKSkFjs6uSSmUAGSrawplXr7+ujuK7W2CgigAHqgDCXCjAiJwUxCzqvPo8ks1BYclZgv9FkcNkVtgCjicKudLtVgqFwiZIjE4roEklyIJup0xqhPjM5rIcARiKQADziSQAGjgAANlgA6AAk6AYygYwQYuAY5CZAD4OgIen0BkMRkTJt4AIJpP6w1LpQ6Q+zQtwq2oNA7go7HTwIgJIij1XG3AQPJ4wF5vD5fRVQZUQ1UZFXrTVbbVulLws6mnX1RqYlqWgQE2UkiDO+YUogkMC0iRiRlMsRpDnoTbFcjZ7m8kz8wUipJAA

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions