TypeScript icon indicating copy to clipboard operation
TypeScript copied to clipboard

tsc with allowJs reports TS9005 error for nested anonymous constructor functions

Open brian6932 opened this issue 1 year ago • 0 comments

🔎 Search Terms

TS9005: Declaration emit for this file requires using private name '(Anonymous function)'. An explicit type annotation may unblock declaration emit.

🕗 Version & Regression Information

  • Occurs in nightly
  • This changed in commit or PR #5472
  • This is the behavior in every version I tried

Related to #55172 When 2 separate nested this bindings are used within constructor functions, the following error's returned always at the top of the file (this was really annoying to debug 😅)

Declaration emit for this file requires using private name '(Anonymous function)'. An explicit type annotation may unblock declaration emit.

⏯ Playground Link

https://tsplay.dev/NV57Gw

💻 Code

const a = new function () {
	this.b = new function () {
		this.c = 1
	}
}

🙁 Actual behavior

Complains

🙂 Expected behavior

Shouldn't complain

Additional information about the issue

No response

brian6932 avatar Feb 24 '24 16:02 brian6932