1

Closed

Compiler does not detect module and class names that are the same

description

Hi,

The TypeScript compiler does not give a syntax error when the module and a class in the module have the same name. The resulting generated code will never work. I would like to suggest adding a syntax error for this problem.

Regards
Paul
Closed Aug 29, 2013 at 8:54 PM by danquirk
This is by design. TypeScript 0.9.0 specifically added a feature called declaration merging to enable scenarios like this when it makes sense. It is an error when the module is defined first, but if the class is defined first then the module and class with the same name are merged, essentially allowing the module to define additional static data for the class. You can see the full details in the language specification in section 10.5

comments