Assume that I'm coding a library in javascript, with typescript declaration files, and I want to create the "shape" of the library instance via interface, like that:
export interface Library {
foo: string;
bar: string;
}
Now assume that foo and bar type would be more complex and I want to carry it out to distinct type alias like:
export type ID = string | number;
export interface Library {
foo: ID;
bar: ID;
}
Now I want to give some sense to ID (cause the "id" doesn't tell a thing), and the only way I think I can do this is to move it to distinct namespace, which is essensially should be named as library - "Library":
export namespace Library {
export type ID = string | number;
}
export interface Library {
foo: Library.ID;
bar: Library.ID;
}
Though it works, it's confusing and ambiguous because one import would be two different things at same time
How do I solve this? Maybe some naming tip?