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

O.Optional key param has changed, using any breaks the type #137

Closed
tonivj5 opened this issue Aug 3, 2020 · 1 comment
Closed

O.Optional key param has changed, using any breaks the type #137

tonivj5 opened this issue Aug 3, 2020 · 1 comment
Labels
limitation We're limited here works as intended It works this way

Comments

@tonivj5
Copy link

tonivj5 commented Aug 3, 2020

馃悶 Bug Report

Describe the bug

In 6.13.36 this type worked right using any as Key param, now it doesn't

Reproduce the bug

type Test = O.Optional<{ test: { subtest: string } }, any, 'deep'>;
const test: Test = null;
// test has this type
// const test: {
//   [x: string]: OptionalDeep<any>;
// }

Expected behavior

Expected type (as in 6.13.36):

const test: {
    test?: OptionalDeep<{
        subtest: string;
    }>;
}

Possible Solution

Using A.Key as Key param works 馃憤

type Test = O.Optional<{ test: { subtest: string } }, A.Key, 'deep'>;

Screenshots

Additional context

I'm using latest typescript version (3.9.7).

This worked before, but maybe this is the expected behavior 馃槄

@millsp millsp added limitation We're limited here wontfix This will not be worked on works as intended It works this way labels Aug 3, 2020
@stale stale bot removed the wontfix This will not be worked on label Aug 3, 2020
@millsp
Copy link
Owner

millsp commented Aug 3, 2020

Hey @tonivj5, thanks for reporting this, I know. The reason that this was working before is a bug that I corrected. This now behaves like any other mapped type should. Sorry about this! And yes, you should always use A.Key:

type t0 = Pick<{a: 1, b: 2}, any> // {[x: string]: any}

Cheers!

@millsp millsp closed this as completed Aug 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
limitation We're limited here works as intended It works this way
Projects
None yet
Development

No branches or pull requests

2 participants