Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

## 馃悶 Bug Report #218

Closed
millsp opened this issue Mar 6, 2021 · 1 comment
Closed

## 馃悶 Bug Report #218

millsp opened this issue Mar 6, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@millsp
Copy link
Owner

millsp commented Mar 6, 2021

馃悶 Bug Report

Describe the bug

For this signature:

function pick<T extends Record<string, any>, K extends string> (obj: T, keys: F.AutoPath<T, K>[]): O.P.Pick<T, S.Split<K, '.'>>

this works:
image

however, adding a second key breaks the nested pick:
image

Reproduce the bug

// REPL or a link to your repository if applicable.
// A *self-contained* demonstration of the problem.

Is it possible to use TS Toolbelt in the typescript TS Playground? If so it's easy for me to replicate this.
Otherwise I can set up a branch on my package if you like.

Possible Solution

I'm not sure!

Originally posted by @mesqueeb in #216

@millsp
Copy link
Owner Author

millsp commented Mar 6, 2021

It happens that I forgot to distribute O.P utilities. I took the day to rewrite all of them. Nous you can do:

import {F, O, S} from 'ts-toolbelt'

declare function pick<T extends Record<string, any>, K extends string>(
    obj: T,
    keys: F.AutoPath<T, K>[]
): O.P.Pick<T, S.Split<K, '.'>>

type O = {
    a: {
        b: O
        c: 1
    }
}
const a = pick({} as O, ['a', 'a.b', 'a.b.a.c'])

@millsp millsp added the bug Something isn't working label Mar 6, 2021
@millsp millsp closed this as completed Mar 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant