Currently in the process of transitioning an existing JavaScript application to TypeScript. To facilitate a gradual conversion, I began by utilizing the "allowJs" compiler option to compile the original JavaScript code. However, as I start converting files to TypeScript, I encounter issues with namespace creation.
For instance, consider these two files: a new TypeScript file:
namespace myapp {
export var c1 = 5;
}
And an old JavaScript file:
var myapp = myapp || {};
myapp.c2 = 4;
While this may result in valid JavaScript output, it triggers an error:
error TS2300: Duplicate identifier 'myapp'.
Is there a workaround to prevent this error or another method for converting files that share the same namespace?
Here is my tsconfig.json:
{
"compilerOptions": {
"allowJs": true,
"outDir": "dist"
}
}