-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Types of property length are incompatible when extending tuple types. #20539
Comments
This is due to #17765. type UnionizeTuple<T extends { readonly [x: number]: any }> = T[number];
type a = ['hi', 'there']
type b = UnionizeTuple<a> |
That's clever. Looks like it works well in all of my cases in my main codebase as well. Thanks for your help! |
I dont understand Andy's solution. I too updated to latest TS and now I get this error: export const AppConfigData: AppConfig = {
|
In your interface you have this: arrayStrLanguagesSupported: [ {...} ] This tells typescript that this property is a tuple (array with known length [1 in this case]) with one object in it. You instead should tell it to use an array type: arrayStrLanguagesSupported: {...}[] |
Awesome! Thanks . That fixed it :) |
thanks! |
TypeScript Version: [email protected]
Code
Expected behavior:
Actual behavior:
This is working as expected in all previous versions of typescript. Updated to the latest typescript@next this morning and this broke. I see why this happened, by being smarter about how we process tuples we can know at compile time the length of a tuple. But because there are not variadic kinds, there is no other way to accomplish the above (or much more complicated examples as I am using elsewhere).
The text was updated successfully, but these errors were encountered: