Skip to content

Latest commit

 

History

History
31 lines (25 loc) · 1.5 KB

File metadata and controls

31 lines (25 loc) · 1.5 KB

ToPrimitive medium

by 前端子鱼 @mwc

Take the Challenge    简体中文

Convert a property of type literal (label type) to a primitive type.

For example

type X = {
  name: 'Tom',
  age: 30,
  married: false,
  addr: {
    home: '123456',
    phone: '13111111111'
  }
}

type Expected = {
  name: string,
  age: number,
  married: boolean,
  addr: {
    home: string,
    phone: string
  }
}
type Todo = ToPrimitive<X> // should be same as `Expected`

Back Share your Solutions Check out Solutions