-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Template literal in string pattern index signature error #46309
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
I think I've explained what's going on in my answer to your SO question. As it stands the code here fails because To the extent that this issue differs from #13948, maybe it can be seen as a suggestion not to widen pattern template literal computed keys (as opposed to unions of string literals)? |
I think Stack Overflow is better suited to Q/A than GitHub is. The easiest workaround is just a type assertion, otherwise you can try to build helper functions to make up for the missing functionality, like this. My answer in Stack Overflow goes through these. |
This issue has been marked as 'Question' and has seen no recent activity. It has been automatically closed for house-keeping purposes. If you're still waiting on a response, questions are usually better suited to stackoverflow or the TypeScript Discord community. |
Bug Report
π Search Terms
template literal string pattern
π Version & Regression Information
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
π Expected behavior
I don't understand why there is an error. If i remove the "name" key, the error goes away.
If i replace the templated string with a literal string
added_abc
the error goes awayThe text was updated successfully, but these errors were encountered: