Skip to content

Numeric string key is being converted to a number in declaration file #50358

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

Closed
tinytim84 opened this issue Aug 18, 2022 · 1 comment · Fixed by #50781
Closed

Numeric string key is being converted to a number in declaration file #50358

tinytim84 opened this issue Aug 18, 2022 · 1 comment · Fixed by #50781
Assignees
Labels
Fix Available A PR has been opened for this issue Needs Investigation This issue needs a team member to investigate its status.

Comments

@tinytim84
Copy link

Bug Report

When TS converts a specific type into a static type in a d.ts file, it's converting numeric string keys into a number, e.g. '1' becomes 1. It seems similar to the issue described here, but my value is being re-mapped with generics and mapped types, so it seems like it's a more complicated version of this. The .d.ts tab in the playground link shows what is happening.

🔎 Search Terms

numeric string key converted to number

🕗 Version & Regression Information

TS 4.7.4

⏯ Playground Link

Playground link with relevant code

💻 Code

It's an issue with compilation, the playground link above shows it.

🙁 Actual behavior

Conversion of a specific type with mapped keys to a static type is resulting in string numeric keys being converted to numbers. e.g. '0', '1', getting converted to 1,2.

🙂 Expected behavior

Keys to remain as strings and not be converted to a number.

@fredericoo
Copy link

I’m facing this in 4.9.4. Am I missing something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fix Available A PR has been opened for this issue Needs Investigation This issue needs a team member to investigate its status.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants