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
With a generic function returning a function that has an argument base return type, which is later passed to another function.
It then is accepted by the later function even if the type used in the generic are incompatible.
For example a custom react hook which is passed down components.
When not the exact return type is used, but instead new type is written with the same structure.
Then the incomparibility in the type used as generic is detected.
🔎 Search Terms
returned
function
generic
🕗 Version & Regression Information
Tested on 5.0.2 (Playground)
The syntax was accepted down to 4.7.4, all versions respond the same.
This is the behavior in every version I tried (down to 4.7.4, below the syntax is not accepted, and I reviewed the FAQ for entries about generics
Bug Report
With a generic function returning a function that has an argument base return type, which is later passed to another function.
It then is accepted by the later function even if the type used in the generic are incompatible.
For example a custom react hook which is passed down components.
When not the exact return type is used, but instead new type is written with the same structure.
Then the incomparibility in the type used as generic is detected.
🔎 Search Terms
returned
function
generic
🕗 Version & Regression Information
Tested on 5.0.2 (Playground)
The syntax was accepted down to 4.7.4, all versions respond the same.
⏯ Playground Link
Playground link with relevant code
Playground link with working alternative
💻 Code
🙁 Actual behavior
getValue is accepted as correct type for pass.
🙂 Expected behavior
getValue is missing 'needed' which is required by pass.
With alternative solution, changing TGetValue from ReturnType to a type on its own:
This report 'needed' is missing.
With this alternative code, when using version 3.3.3 it also accepts getValue like it does when using ReturnType.
The text was updated successfully, but these errors were encountered: