Las demostraciones de TypeScript

El autor:El inventor de la cuantificación, Fecha: 2023-03-21 16:34:56
Las etiquetas:

La plataforma incluye el soporte nativo de TypeScript, solo al inicio del código fuente (tipo de lenguaje estratégico o JavaScript seleccionado)

// @ts-check

Se reconoce automáticamente como TypeScript.


// @ts-check

class Greeter {
    greeting: string;

    constructor(message: string) {
        this.greeting = message;
    }

    greet() {
        return "Hello, " + this.greeting;
    }
}


function peopleName(firstName: string, ...restOfname: string[]) {
    return firstName + " " + restOfname.join(" ");
}


function main() {
    let greeter = new Greeter("world");
    Log(greeter.greet());

    
    Log(peopleName('xiaochuan', 'xiaoming', 'xiaohong'))
}



Más.