declare type Item = {
name: string;
location: string;
source: string;
};
declare type CollectionOfItems = {
[key: string]: Item;
};
export const CollectionOfItems: CollectionOfItems = {
ITEM_1: {
name: 'Item 1',
location: 'path/item1',
source: 'source_item_1',
},
ITEM_2: {
name: 'Item 2',
location: 'path/item2',
source: 'source_item_2',
},
} as const;
If I add the CollectionOfItems
type annotation, IntelliSense disappears. Removing the type brings it back. How can I accurately define my constant Object while maintaining IntelliSense functionality?
I aim to effortlessly include a new item, like "ITEM_3"
, and benefit from IntelliSense throughout my project.