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

Template Literals in Record #43618

Closed
Sharcoux opened this issue Apr 9, 2021 · 2 comments
Closed

Template Literals in Record #43618

Sharcoux opened this issue Apr 9, 2021 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@Sharcoux
Copy link

Sharcoux commented Apr 9, 2021

Bug Report

🔎 Search Terms

Template literals index Record

🕗 Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about Template Literals
  • I was unable to test this on prior versions because template literal didn't exist

⏯ Playground Link

Playground link with relevant code

💻 Code

// We can quickly address your report if:
//  - The code sample is short. Nearly all TypeScript bugs can be demonstrated in 20-30 lines of code!
//  - It doesn't use external libraries. These are often issues with the type definitions rather than TypeScript bugs.
//  - The incorrectness of the behavior is readily apparent from reading the sample.
// Reports are slower to investigate if:
//  - We have to pare too much extraneous code.
//  - We have to clone a large repo and validate that the problem isn't elsewhere.
//  - The sample is confusing or doesn't clearly demonstrate what's wrong.

type IdType = `${number}-${number}-${number}-${number}`
const id: IdType = '0000-0000-0000-0001';

type A = Record<IdType, string>

const a: A = {
    [id]: 'test'
}
a[id] // Element implicitly has an 'any' type because expression of type '`${number}-${number}-${number}-${number}`' can't be used to index type 'A'.(7053)

🙁 Actual behavior

Element implicitly has an 'any' type because expression of type '`${number}-${number}-${number}-${number}`' can't be used to index type 'A'.(7053)

🙂 Expected behavior

ts be happy, cause I love my ts happy.

@jcalz
Copy link
Contributor

jcalz commented Apr 9, 2021

Duplicate of #42192

@andrewbranch andrewbranch added the Duplicate An existing issue was already created label Apr 9, 2021
@typescript-bot
Copy link
Collaborator

This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

4 participants