Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

typescript get type of object property

type Data = {
  value: number;
  text: string;
};
type textProperty = Data["text"]; //string

//OR
const data = {
  value: 123,
  text: 'hello'
};
type textProperty = typeof data["text"]; //string
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #typescript #type #object #property
ADD COMMENT
Topic
Name
3+3 =