CyberFox
CyberFox

Reputation: 810

Duplicate Identifier in duplicate module

I have 2 files which contain the same module in my solution (different projects).

module myModule{
    export function doStuff(){} // in here "doStuff" is getting redlined
}

This error is obviously because i have 2 files with the same piece of code in it. But seeing as they don't reference each other or anything for that matter, i don't see how they can conflict.

Upvotes: 1

Views: 908

Answers (1)

Fenton
Fenton

Reputation: 251242

If you are using Visual Studio, it treats all files as implicitly references all TypeScript files.

Therefore, if it thinks both modules have the same common root, it will think one is an extension of the other and will try to warn you about duplicate declarations.

Although you could argue that they aren't the same module, it is worth drawing some inspiration from framework class libraries, where they rarely rely on namespaces alone to distinguish between two classes, for example both of the following could have been called Command, but they have been distinguished by class name as well as namespace:

  • System.Data.SqlClient.SqlCommand
  • System.Data.OracleClient.OracleCommand

Upvotes: 1

Related Questions