Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

ts object field from variable

// use braces to access an object field from a variable
// use keyof to remove the 'any' type error

activeVideo = videos[target.value as keyof IVideoData];
Source by www.nadershamma.dev #
 
PREVIOUS NEXT
Tagged: #ts #object #field #variable
ADD COMMENT
Topic
Name
8+5 =