I have a package where the src
with the following structure:
┌────────┐ ┌───────┐
│moduleA │─┬── │code.ts│
└────────┘ │ └───────┘
│ ┌──────────┐
├── │code.d.ts │
│ └──────────┘
│ ┌──────────┐
└── │types.d.ts│
└──────────┘
where the code.d.ts
has the definitions of the exports of code.ts
and types.d.ts
hold a namespace
for the types used in code.d.ts
. This works well in the package but when I export it the namespace is not recognized in the code.d.ts
file anymore. Also every article about how to export types is quite confusing. Can someone point me into a direction where to start figuring this out.
code.ts
export default class MyClass {
createSubject(id: string): Promise<MyNamespace.Subject> {
return this.put(`/subjects/${id}`)
}
code.d.ts
export default class MyClass {
createSubject(id: string): Promise<MyNamespace.Subject>
type.d.ts
declare namespace MyNamespace {
export interface Subject {
id: String
}
}
The code is auto generated from openAPI files, so type.d.ts
just represent the types from the openAPI file and code.ts
is a simple class with a method for every existing endpoint.