Microsoft/TypeScript

tsc with allowJs reports TS9005 error for nested anonymous constructor functions

Open

#57,523 建立於 2024年2月24日

在 GitHub 查看
 (6 留言) (0 反應) (0 負責人)TypeScript (6,726 fork)batch import
Domain: Declaration EmitHelp WantedPossible Improvement

倉庫指標

Star
 (48,455 star)
PR 合併指標
 (平均合併 6天 17小時) (30 天內合併 9 個 PR)

描述

🔎 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 on versions 3.7.5 - nightly
  • Related to PR #55472

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

貢獻者指南