Is there a way to assign to namespaces using dot notation like this?
namespace item {}
item.item1 = {
name: "Some Item"
}
item.item2 = {
name: "Some Item"
}
An error is thrown with:
Property 'item1' does not exist on type 'typeof item'.
An alternative approach that works involves:
namespace item {
export const item3 = {
name: "Some Item"
}
}
namespace item {
export const item4 = {
name: "Some Item"
}
}
However, this solution is verbose and unattractive. Is there a way to make the initial version work by modifying the namespace declaration? For example:
namespace item {
[key: string]: ItemType
}
My goals are:
- To have intellisense autocomplete for
item.
, displaying item1, item2, etc. - To organize items in separate files instead of all within the same bracket.