I'm tackling a Typescript query related to namespaces and organizing files. Within a single namespace, I have multiple interfaces and classes that I'd like to separate into individual .ts
files. The goal is to then combine these files so that when I declare the namespace in another code file, I can easily access all the interfaces and classes within it. To illustrate, let's start with the first file, icontact.ts
:
export namespace mynamespace {
export interface IContact {
firstName: string;
lastName: string;
}
}
Moving on to the second file, contact.ts
:
import {IContact} from './icontact.ts';
export namespace mynamespace {
export class Contact implements IContact {
firstName: string;
lastName: string;
constructor(firstName: string, lastName: string){
this.firstName = firstName;
this.lastName = lastName:
}
}
}
If anyone could lend a hand with this setup, I would be extremely grateful.
Many thanks in advance.