We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Here is the code I've got an error.
class Foo<T, K extends keyof T> { sayHi(name: K | K[]) { console.log(`hi ${name}`); } } interface Event { click(element: string, event: object):void touch(element: string, event: object):void } const f = new Foo<Event>(); // TS2558: Expected 2 type arguments, but got 1.
Where K is a type that is determined by T automatically, so typescript compiler should not allow users to specify the K type parameter manually.
K
T
Did I miss any use cases that a user should specify K manually?
If the K can be an "optional type parameter" that can be specified by user manually , the format should be this I suppose.
class Foo<T, K = keyof T> { }
By now I'm using this format to avoid the error. But I think this is so pointless..
class Foo<T, K extends keyof T = keyof T> { }
The text was updated successfully, but these errors were encountered:
See #16597 and others
Sorry, something went wrong.
This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.
No branches or pull requests
Here is the code I've got an error.
Where
K
is a type that is determined byT
automatically, so typescript compiler should not allow users to specify theK
type parameter manually.Did I miss any use cases that a user should specify
K
manually?If the
K
can be an "optional type parameter" that can be specified by user manually , the format should be this I suppose.By now I'm using this format to avoid the error. But I think this is so pointless..
The text was updated successfully, but these errors were encountered: