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.
 
 
 
 
 

14 lines
362 B

// js 中的 typeof
// console.log(typeof 'hello TS')
// TS 中的 typeof
let p = { x: 1, y: 2 }
// function formatPoint(point: {x: number; y: number }) {}
// 使用 typeof,拿到对象 p 中的类型,实现简化书写的目的
function formatPoint(point: typeof p ) {}
formatPoint({ x: 1, y: 100 })
// 查看 p对象中属性 x
let num: typeof p.x