编辑代码

interface labelValue {
    label:string;
    name:string;
    age?:number;//可选属性
    readonly title:string//只读,初始化后不能修改值,否则报错
}

function checkLabel(labelObj:labelValue){
    console.log(labelObj.label,labelObj.name,labelObj.title)
}
let obj = {name:'sss',label:'',age:1,gender:'',title:'123'}

checkLabel(obj)

let obj1:labelValue = {label:'123',name:'111',title:'qqq'};
// obj1.title = 'ppp';
let arr:number[] = [],arr1:string[] = [];
// arr = [12,23,'12']
// arr1 = ['12',2]

interface SquareConfig {
    color: string;
    width?: number;
}

function createSquare(config: SquareConfig):string {
    // ...
    return config.color;
}

let mySquare = createSquare({ color: "red", width: 100 });

console.log('mySquar',mySquare)

class Person{
    private name:string;
    constructor(name:string){
        this.name = name;
    }
    saySomething(){
        console.log(this.name)
    }
}

class shirley extends Person{
    saySomething(){
        console.log('shirley')
    }
}

class person extends shirley{}

let lixian = new shirley('lixian');
lixian.saySomething();
// console.log('person',person)