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

TS2376 doesn't comply with ECMAScript #42400

Closed
ghost opened this issue Jan 19, 2021 · 1 comment
Closed

TS2376 doesn't comply with ECMAScript #42400

ghost opened this issue Jan 19, 2021 · 1 comment
Labels
Duplicate An existing issue was already created

Comments

@ghost
Copy link

ghost commented Jan 19, 2021

Bug Report

πŸ”Ž Search Terms

First statement must be super

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about super calls in classes

⏯ Playground Link

Couldn't provide a link, TS playground wasn't working, I've opened microsoft/TypeScript-Website#1506

πŸ’» Code

class T extends Number {
	x = 0; // use class instance field
	constructor(n: number) {
		const temp = n ** n; // do something
		super(temp); // not first statement
	}
};

console.log(new T(10).valueOf());

πŸ™ Actual behavior

TSC raises error TS2376, claiming that super calls must be the first statement in a class, if a class uses the class instance field.

πŸ™‚ Expected behavior

TSC removes the : number, and ends process.
Removing type annotations, this is otherwise perfectly valid ES.


Possibly related to #6908

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Jan 19, 2021
@RyanCavanaugh
Copy link
Member

Duplicate #8277

@ghost ghost closed this as completed Jan 19, 2021
This issue was closed.
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

1 participant