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
type broadening, type narrowing, generics, generic type parameter, index type, template literal, typescript, unexpected, why doesn't typescript know that these are the same, same generic instance not enforced between function params
🕗 Version & Regression Information
This is the behavior in every version I tried, and I reviewed the FAQ for entries about the same generic instance type being used in different function parameters
The actual type of ${field}.${option} is some sort of cartesian product of the types of field and option, causing the TemplateType type of myTemplate to be incorrect.
🙂 Expected behavior
The type of ${field}.${option} should be either "Something.Something" or "SomethingElse.SomethingElse" based on the same T being enforced between the two params.
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered:
See #57372 (comment). T can legally be instantiated to Something | SomethingElse in which case the parameters don't have to correlate. You're looking for #27808.
🔎 Search Terms
type broadening, type narrowing, generics, generic type parameter, index type, template literal, typescript, unexpected, why doesn't typescript know that these are the same, same generic instance not enforced between function params
🕗 Version & Regression Information
⏯ Playground Link
https://www.typescriptlang.org/play#code/C4TwDgpgBAyg9gWwsAFgSwHYHMoF4oDk8SqmWBA3AFCiSyLLrYCiANgM7T5EOkscRKVGuGgAVCAjCsAhsAhjReKAANijMgDoAJAG91fLAF8VUAD6qDTLG0479va7YgnhAMwCuGAMbA0cDCgAEzgrMgB1NFQAWRAxawAeMSgIAA95DCD2ehJrcxyNfk4APgAKNzQIViCALigxABooODA-ALqxAEooXSoofqhvAPZgKAQ4yWk5CA7J2XlFOnwVPQqqoKN7FraME2ojKiA
💻 Code
🙁 Actual behavior
The actual type of
${field}.${option}
is some sort of cartesian product of the types of field and option, causing theTemplateType
type ofmyTemplate
to be incorrect.🙂 Expected behavior
The type of
${field}.${option}
should be either "Something.Something" or "SomethingElse.SomethingElse" based on the sameT
being enforced between the two params.Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: