Skip to content
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

Extended class's "super" class always assumed to return "void" #39758

Closed
ghost opened this issue Jul 27, 2020 · 3 comments
Closed

Extended class's "super" class always assumed to return "void" #39758

ghost opened this issue Jul 27, 2020 · 3 comments
Labels
Duplicate An existing issue was already created

Comments

@ghost
Copy link

ghost commented Jul 27, 2020

TypeScript Version: 4.0.0-dev.20200725

Code

class T extends Array {
	constructor() {
		console.log(super(10) as any[]);
	};
};

new T;

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).

Playground Link: https://www.typescriptlang.org/play?ts=4.0.0-dev.20200725#code/MYGwhgzhAEDKAuZ4EtgEEBOGwE8A8AKtAKYAe8xAdgCYxiU4DaAugHwnlW3SbY7QBvAFABIYAHtKEeBgCuweOIwAKAHTrklAA6z4ALmgEAlINEiASsQBmIYgtVaMxAG5V4AUU5TkkiMoiyWsQq6qqaOvBGRgDcogC+sQlCQhJS4raqIOIA5sqiljZ28GEQnhTeAEa2eSIilMQA7nCIKOhYuMoAjAA00ABMvQDMvQAsvQCsvQBsvQDsRqILMUA

@ghost 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 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
@MartinJohns
Copy link
Contributor

Duplicate of #37847, tho your issue is slightly better documented. Related to #38519 and #27594.

@ghost
Copy link
Author

ghost commented Jul 28, 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 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
@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Jul 30, 2020
@typescript-bot
Copy link
Collaborator

This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants