In our Visual Studio 2017 project, we have multiple TypeScript files that define a URLs
class. Each file contains different implementations of the class to change site URLs based on the specific use case:
customer/urls.ts
namespace Portal {
export class URLs {
static homePage(): string { return "/customer"; }
}
}
supplier/urls.ts
namespace Portal {
export class URLs {
static homePage(): string { return "/supplier"; }
}
}
This approach leads to a "Duplicate identifier 'URLs'" error in Visual Studio 2017. The IDE assumes that all TypeScript files will be included in the webpage, causing the conflict. However, since only one file is pulled in for any given page, there is no actual duplicate identifier in the browser. How can this error be resolved in Visual Studio or is there a valid reason behind it?