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
Expected behavior:
Compiles cleanly, as super in this case refers to Array, and by using Array(10) we get an array of type any with length === 10. Actual behavior:
TSC seems to think that super returns void, which is incorrect, and inconsistent with ECSMAScript / JavaScript itself. TSC seems to assume super: (...items: any[]) => void while Array's type signature is Array: (...items: any[]) => any[] (or more precisely: Array: <T extends any[]>(...items: T) => T).
The text was updated successfully, but these errors were encountered:
ghost
changed the title
Extended classes super function always assumed to return void
Extended classes "super" function always assumed to return "void"
Jul 27, 2020
ghost
changed the title
Extended classes "super" function always assumed to return "void"
Extended classe's "super" class always assumed to return "void"
Jul 27, 2020
Duplicate of #37847, tho your issue is slightly better documented. Related to #38519 and #27594.
Oh... so should I just close this down?
ghost
changed the title
Extended classe's "super" class always assumed to return "void"
Extended class's "super" class always assumed to return "void"
Jul 28, 2020
TypeScript Version: 4.0.0-dev.20200725
Code
Expected behavior:
Compiles cleanly, as
super
in this case refers toArray
, and by usingArray(10)
we get an array of typeany
withlength === 10
.Actual behavior:
TSC seems to think that
super
returnsvoid
, which is incorrect, and inconsistent with ECSMAScript / JavaScript itself. TSC seems to assumesuper: (...items: any[]) => void
whileArray
's type signature isArray: (...items: any[]) => any[]
(or more precisely:Array: <T extends any[]>(...items: T) => T
).Playground Link: https://www.typescriptlang.org/play?ts=4.0.0-dev.20200725#code/MYGwhgzhAEDKAuZ4EtgEEBOGwE8A8AKtAKYAe8xAdgCYxiU4DaAugHwnlW3SbY7QBvAFABIYAHtKEeBgCuweOIwAKAHTrklAA6z4ALmgEAlINEiASsQBmIYgtVaMxAG5V4AUU5TkkiMoiyWsQq6qqaOvBGRgDcogC+sQlCQhJS4raqIOIA5sqiljZ28GEQnhTeAEa2eSIilMQA7nCIKOhYuMoAjAA00ABMvQDMvQAsvQCsvQBsvQDsRqILMUA
The text was updated successfully, but these errors were encountered: