Answers for "typescript typeof interface property"

6

typescript class interface

interface IPerson {
  name: string
  age: number
  hobby?: string[]
}

class Person implements IPerson {
  name: string
  age: number
  hobby?: string[]

  constructor(name: string, age: number, hobby: string[]) {
    this.name = name
    this.age = age
    this.hobby = hobby
  }
}

const output = new Person('john doe', 23, ['swimming', 'traveling', 'badminton'])
console.log(output)
Posted by: Guest on December-07-2020
2

typescript valueof interface

type ValueOf<T> = T[keyof T];
Posted by: Guest on April-29-2020
0

typescript typeof interface property

interface I1 {
    x: any;
}

interface I2 {
    y: {
        a: I1,
        b: I1,
        c: I1
    }
    z: any
}

let myVar: I2['y'];  // indexed access type
Posted by: Guest on July-09-2021

Code answers related to "typescript typeof interface property"

Browse Popular Code Answers by Language