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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complex mapped types can break symbol resolution #23

Closed
mxsdev opened this issue Nov 14, 2022 · 0 comments
Closed

Complex mapped types can break symbol resolution #23

mxsdev opened this issue Nov 14, 2022 · 0 comments
Labels
api Relating to the API bug Something isn't working
Milestone

Comments

@mxsdev
Copy link
Owner

mxsdev commented Nov 14, 2022

Example:

interface FieldVals {
    string: string;
    number: number
}

type FieldFormat = Record<string, keyof FieldVals>

type MapField<T extends FieldFormat> = {
    [K in keyof T]: FieldVals[T[K]]
}

declare function createField<T extends FieldFormat>(data: T): MapField<T>

const f = createField({a: "string"})

f.a

f.a in the extension will resolve to the symbol a which is of type "string", rather than following the resolution through to FieldVals, which should result in type string.

Thanks to @Didas-git for reporting this/providing the example!

@mxsdev mxsdev added bug Something isn't working api Relating to the API labels Nov 14, 2022
@mxsdev mxsdev added this to the 1.0.0 milestone Nov 14, 2022
@mxsdev mxsdev closed this as completed in a21086c Nov 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Relating to the API bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant