-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Suggestion: automatically infer class method param type #21223
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
Comments
Maybe it isn't all that great if everything is just inferred. Especially in cases like that it could lead to errors because the inferred type might not be what you think it should be. Maybe you mistakenly implemented the wrong interface, maybe you made a mistake in the ancestor interface and wouldn't notice at the time of implementing. Moreover, types serve self-documentation. If I need to know what |
@MarvinHannott Not everything. maybe a @mhegazy Thank you for the links. I 'll check them. |
nah.. these ones are hard to find.. I know them cause i look at them often. |
consider this code snippet
so the compiler knows exactly what type should param
target
to be.but it can't be inferred.
add a simple type to that param should be ok.
but in some cases that
SomeClassType
is not exported directly at all.can ts compiler infer that type from interface restrictions automatically?
Use case:
I'm writing a system which supports loading plugins.
I would like to export a single
Plugin
type to help plugin coders.But it feels bad that
The text was updated successfully, but these errors were encountered: