if you want more type specific then you can do like below
const AVATAR="avatar"
const IMAGE ="image"
type ThumbType= typeof AVATAR | typeof IMAGE
interface A{
id: string;
[key:ThumbType]: string;
thumbnails: {
[key: ThumbType]: {
"50x50": string;
"100x100": string;
}
}
but i prefer more specific definition than dynamic key, like below
interface Resulation{
"50x50": string;
"100x100": string;
}
interface Image{
image: string;
thumbnails:{
image: Resulation
}
}
interface Avatar{
avatar: string;
thumbnails:{
avatar: Resulation
}
}
type PData= (Image| Avatar) &{
id: string;
}
Example:
let x:PData={
id:"A",
image: "imahe",
thumbnails: {
image:{
"50x50": "",
"100x100": "",
}
}
}
let y:PData={
id:"A",
avatar: "imahe",
thumbnails: {
avatar:{
"50x50": "",
"100x100": "",
}
}
}