In my Javascript project, I am trying to define typing for a specific structure. Consider the following simplified example:
a
|
+ A.js
+ b
|
+ B.js
Here we have a folder 'a', and inside it there is another folder 'b'. My goal is to import modules like this:
import { A } from "a"
import { B } from "a/b"
The ideal typing that I want to implement would look something like this:
declare namespace a {
interface A { }
namespace b {
interface B { }
}
}
declare module "a" {
export = a
}
declare module "a/b" {
export = a.b
}
However, when I try to use this setup, I encounter an error stating
Cannot use namespace 'a' as a value
.
I found that changing the interfaces to classes resolves the issue. Can anyone explain why this is the case? Is there a way to achieve the desired definitions using interfaces?