作为函数的参数类型的定义
interface labelobj{label:string}function printLabel(lableObject: labelobj){console.log(lableObject)}printLabel({label:"label"})
可选参数使用 ?
interface labelobj{
label:string
width?: number
}
function printLabel(lableObject: labelobj){
console.log(lableObject)
}
printLabel({label:"label"})
printLabel({label:'abc',width:10})
readonly 不能修改的值
interface Point{
readonly x:number
readonly y:number
}
let p1:Point = {x:10,y:5}
p1.x = 20 // Cannot assign to 'x' because it is a read-only property.

