You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

13 lines
301 B

2 years ago
  1. // js 中的 typeof
  2. // console.log(typeof 'hello TS')
  3. // TS 中的 typeof
  4. let p = { x: 1, y: 2 }
  5. // function formatPoint(point: {x: number; y: number }) {}
  6. // 使用 typeof
  7. function formatPoint(point: typeof p ) {}
  8. formatPoint({ x: 1, y: 100 })
  9. // 查看 p对象中属性 x
  10. let num: typeof p.x