I am new to TypeScript, normally we can do somethin like this:
interface IPerson {
name: string,
age: number
}
const tim:IPerson = {
name: 'Tim',
age: 21
}
above codes, "tim" object need to include name
(with string value) and age
(with number value) properties.
So my question is, can I do the same thing with new Map()
? (like the codes above, must include name
(name value must be string) and age
(age value must be number) properties.)
I did tried creating some generic Interfaces and types but I don't think I am doing it right, because none of the work.