Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

typescript array of possible object keys

const keyOptions = ["name", "gender", "address"] as const;
type TCustomKeys = { [key in typeof keyOptions[number]]: any };

const obj: TCustomKeys = {
  name: "James",
  gender: "M",
  address: "1 First Rd"
}; // no errors, and intellisense working
Comment

PREVIOUS NEXT
Code Example
Typescript :: Cannot choose between the following variants of project :react-native-camera: 
Typescript :: append to array mongoose updateone 
Typescript :: window ethereum types 
Typescript :: how to connect postgress server in pgadmin 
Typescript :: Material-ui icon npm 
Typescript :: echarts is not defined 
Typescript :: typescript method comments 
Typescript :: big brackets latex 
Typescript :: export class typescript 
Typescript :: difference between test strategy vs test plan 
Typescript :: nginx ERR_TOO_MANY_REDIRECTS when i try redirect to https 
Typescript :: array contains typescript 
Typescript :: styled components if else 
Typescript :: reactnative upload image axios 0.66 
Typescript :: how to call a export constants in nodejs 
Typescript :: eslint airbnb react typescript 
Typescript :: typescript get class properties 
Typescript :: wordpress get_posts custom posts by meta key 
Typescript :: Publication only contains dependencies and/or constraints without a version. You need to add minimal version information, publish resolved versions 
Typescript :: brackets latex 
Typescript :: angular innerhtml style 
Typescript :: distance using the constant velocity formula 
Typescript :: form reset typescript 
Typescript :: install microsoft fonts on ubuntu 20.04 
Typescript :: locking value of cell 
Typescript :: typescript axios 
Typescript :: --skip tests generate components - Angular 12 - skip-tests vs spec-false 
Typescript :: how push objects into a local stotage array 
Typescript :: rails precompile assets in a directory 
Typescript :: Create Type from String Enum 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =