-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Cannot create rest type from generic type #23246
Comments
A doesn't has to be an object.
I just tested it with version 2.7.2, and your code does not work there either. Also it seems to be a duplicate of #10727 and will hopefully someday be implemented with #13288. |
1. interface A { bla: 3; } does not work either. and that is an object. If something extends that interface, it is an object, too. So yes, it is a bug :) and:
can be an object, but
must be an object. did not believe it. but it is true. you're right a novice would just a assume that case 1 is an object without a property. and i am no novice (in TS) for me something like this can be an object:
I'm gonna post my tsconfig, just in case it you test it in 2.7.1 and it work's there too (it shoud not)
it extends this:
|
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed. |
TypeScript Version: 2.8.1 (vs code newest)
Search Terms: rest parameter destructuring generic
Code
Expected behavior: no error (because TA extends A, and A is an object, and rest parameters should work with objects...).
It worked with ts 2.7.2, but NOT with 2.8.1
Actual behavior: see pic
Playground Link: http://www.typescriptlang.org/play/index.html#src=interface%20A%20%7B%7D%0D%0A%0D%0Aclass%20MyClass%3CTA%20extends%20A%3E%7B%0D%0A%20%20%20%20method()%20%7B%0D%0A%20%20%20%20%20%20%20%20const%20a%3A%20A%20%3D%20null%20as%20any%3B%0D%0A%20%20%20%20%20%20%20%20const%20%7B%20...props1%20%7D%20%3D%20a%3B%0D%0A%20%20%20%20%20%20%20%20const%20ab%3A%20TA%20%3D%20null%20as%20any%3B%0D%0A%0D%0A%0D%0A%0D%0A%20%20%20%20%20%20%20%20const%20%7B%20...props2%20%7D%20%3D%20ab%3B%0D%0A%20%20%20%20%7D%0D%0A%7D%0D%0A
Related Issues:
The text was updated successfully, but these errors were encountered: