You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Infer Subtypes from Template Literal TypesΒ #43907
I was able to kind of work around this limitation by using the string value "0" instead of ${number}, and then converting that to ${number} later down the road.
It seems to randomly cause "Type instantiation is excessively deep and possibly infinite". I'm open to other workarounds that might not cause so much recursion if anyone has any! You can see changes here, I marked the comments with CHANGE:
For a real world example, here is Formik with the above integration, with strongly typed Fields which enforce valid name, value, child component, or parse / format function. There are a lot of variants on the core Field component, so testing it is unfortunately very verbose.
Activity
johnrom commentedon Apr 30, 2021
I was able to kind of work around this limitation by using the string value "0" instead of
${number}, and then converting that to ${number} later down the road.It seems to randomly cause "Type instantiation is excessively deep and possibly infinite". I'm open to other workarounds that might not cause so much recursion if anyone has any! You can see changes here, I marked the comments with CHANGE:
Playground
johnrom commentedon Apr 30, 2021
For a real world example, here is Formik with the above integration, with strongly typed Fields which enforce valid
name,value, child component, or parse / format function. There are a lot of variants on the core Field component, so testing it is unfortunately very verbose.https://codesandbox.io/s/serene-napier-4wjxs?file=/src/App.tsx
DanielRosenwasser commentedon May 1, 2021
This seems to work in nightlies, right?
DanielRosenwasser commentedon May 1, 2021
Check it out using a nightly release of TypeScript
DanielRosenwasser commentedon May 1, 2021
(Fixed by #43361, duplicate of #43243)
typescript-bot commentedon May 3, 2021
This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.