Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

typescript array with allowed 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 :: ggplots in r 
Typescript :: running scripts is disabled on this system 
Typescript :: typescript window ethereum 
Typescript :: unable to connect to postgresql server fatal password authentication failed for user 
Typescript :: regex match round brackets contains any characters 
Typescript :: react forwardref typescript 
Typescript :: contents links python jupyter 
Typescript :: loop through string typescript 
Typescript :: laravel custom exists rule 
Typescript :: get key of enum typescript 
Typescript :: gradients colors in android 
Typescript :: output requirements conda 
Typescript :: clone object in typescript 
Typescript :: Check restore percentage tsql 
Typescript :: how to create dict key with list default -1 
Typescript :: how to remove last 2 elements from list in python 
Typescript :: google sheets reference cell static 
Typescript :: sheets column number to letter 
Typescript :: dynamic subplots matplotlib 
Typescript :: mocha test typescript 
Typescript :: typescript array of mixed types 
Typescript :: react-router-dom for typescript 
Typescript :: react-native-typescript issue 
Typescript :: NullInjectorError: R3InjectorError(DynamicTestModule)[AdminTestCentersComponent - ToastrService - InjectionToken ToastConfig - InjectionToken ToastConfig]: NullInjectorError: No provider for InjectionToken ToastConfig! 
Typescript :: absolute cell reference in excel and google sheets 
Typescript :: typescript api request header 
Typescript :: how to add 2 bind events on one button tkinteer 
Typescript :: react typescript cheat sheet 
Typescript :: object add property typescript 
Typescript :: stripe create customer 
ADD CONTENT
Topic
Content
Source link
Name
9+2 =