You can declare colors
as any
to tell TypeScript to get off your back on this one (aka explicit any):
const color : any = {
red: null,
green: null,
blue: null
};
But if possible, strong typing is preferable:
const color : { [key: string]: any } = {
red: null,
green: null,
blue: null
};
More information on indexing in TypeScript: Index Signatures
EDIT: In this answer to a similar question, the author suggest using a Map<,>
-- if that fits your use-case.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…