Answers for "typescript get type of object property"

0

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
Posted by: Guest on May-07-2021
2

typescript type of object values

const data = {
  value: 123,
  text: 'text'
};
type Data = typeof data["text"]; 		// String
Posted by: Guest on April-29-2021

Code answers related to "typescript get type of object property"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language