Answers for "typescript type of object values"

5

typescript type object

type Dictionary = {
  [key: string]: any
}
Posted by: Guest on May-11-2021
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

object type in typescript

declare function create(o: object | null): void;
// OKcreate({ prop: 0 });create(null);create(undefined); // with `--strictNullChecks` flag enabled, undefined is not a subtype of nullArgument of type 'undefined' is not assignable to parameter of type 'object | null'.2345Argument of type 'undefined' is not assignable to parameter of type 'object | null'.
create(42);Argument of type '42' is not assignable to parameter of type 'object | null'.2345Argument of type '42' is not assignable to parameter of type 'object | null'.create("string");Argument of type '"string"' is not assignable to parameter of type 'object | null'.2345Argument of type '"string"' is not assignable to parameter of type 'object | null'.create(false);Argument of type 'false' is not assignable to parameter of type 'object | null'.2345Argument of type 'false' is not assignable to parameter of type 'object | null'.Try
Posted by: Guest on May-12-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 type of object values"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language