I'm new to TypeScript, sorry if my question is dumb. Is there a way to point out the indexing for this type so that it use it's own keys instead of just an object?
export type TypeAbCreationModal = {
[index: string]: object | TypeExperience;
name: {
title: string;
placeholder: string;
};
server: {
title: string;
tooltip: string;
};
site: {
title: string;
placeholder: string;
placeholderSearch: string;
};
};
Edit:
Object typed with TypeAbCreationModal looks like this :
const myObj = {
name: {
title: 'Some Title',
placeholder: 'Some Placeholder',
},
server: {
title: 'Some Title',
tooltip: 'Some Tooltip',
},
site: {
title: 'Some Title',
placeholder: 'Some Placeholder',
placeholderSearch: 'Some Placeholder',
},
}
At some point I'll have to access it like this
myObj[someIndex].title
(someIndex is of the TypeExperience type)
If I use an object as an index TS throws an error "title can not assign to object"