Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # 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
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
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Bug A bug in TypeScript Help Wanted You can do this
Projects
None yet
Development

No branches or pull requests

2 participants