I'm trying to achieve the following: (Never mind that the types are structured the same. This is for demo purpose only). The goal is to not have a single large file for the namespace I'd like to export.
import Animal from 'types/animal/index.ts'
const dog:Animal.Dog = {
sound: 'bark',
legs: 4
}
const cat:Animal.Cat = {
sound: 'meow',
legs: 4
}
types/animal/index.ts
// somehow import the animal types from separate files and export in one "Animal" namespace
types/Cat.ts
export namespace Animal {
export interface Cat {
sound: string
legs: number
}
}
types/Dog.ts
export namespace Animal {
export interface Dog {
sound: string
legs: number
}
}