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

Error "Class name cannot be 'Object' when targeting ES5 with module CommonJS." when not targeting es5 #61270

Open
CraigMacomber opened this issue Feb 25, 2025 · 0 comments · May be fixed by #61358
Labels
Bug A bug in TypeScript Help Wanted You can do this
Milestone

Comments

@CraigMacomber
Copy link

🔎 Search Terms

Object ES5 Error

🕗 Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about this.

⏯ Playground Link

https://www.typescriptlang.org/play/?target=11&module=1&ts=5.9.0-dev.20250225#code/HYQwtgpgzgDiDGEAEANJBvJ8A2IpSQHkAjAKwngBcMBfJGoA

💻 Code

namespace X { class Object {} }

Target CommonJS and some new target, like ES2024.

🙁 Actual behavior

Class name cannot be 'Object' when targeting ES5 with module CommonJS.

Error mentions ES5 when ES5 is not being targeted.

🙂 Expected behavior

One of:

  • No error
  • Error mentions target being used
  • Error does not mention target

Additional information about the issue

This same error happens with Node16 module resolution when module's format is CommonJS.

@RyanCavanaugh RyanCavanaugh added Bug A bug in TypeScript Help Wanted You can do this labels Feb 27, 2025
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Help Wanted You can do this
Projects
None yet
2 participants