Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

typescript keyof object

type staffKeys = 'name' | 'salary';
function getProperty<T, K extends staffKeys>(obj: T, key: K): T[K] {
return obj[key];
}
Source by blog.logrocket.com #
 
PREVIOUS NEXT
Tagged: #typescript #keyof #object
ADD COMMENT
Topic
Name
3+4 =