I have an array:
const mediaFileKeys = ["mp3", "wave", "stems", "image"];
And i need it to have explicit value types.
So i copied and pasted its values:
const mediaFileKeys: ["mp3", "wave", "stems", "image"] = ["mp3", "wave", "stems", "image"];
Is there any way of doing that without having to copy the array values?
CodePudding user response:
Just use the as const
assertion:
const mediaFileKeys = ["mp3", "wave", "stems", "image"] as const;