This is the simplified code
export interface MyInterface{
// Have no idea why I need an export here.
// If I remove it, it gives
// semantic erro
TS2451 Cannot redeclare block-scoped variable 'createClass'
This error occurs because you have createClass
function somewhere else in your ambient environment. Ambient means, not scoped by modules. Writing at least one import
or export
scopes your file, i.e. makes it a module.
Instead of exporting random interface you could just do this: export {}
in the end of the file.
const MyClass = createClass(); const mc: MyClass
In the above code you are mixing types with values. Specifically, MyClass
is a value here and you are trying to use it as a type.
Overall, you are doing weird things by returning a class by a function. I know you might have your own reasons for that, but normally you should write that code like this:
class MyClass {}
const mc: MyClass = new MyClass() // thought the type annotation is not necessary