TypScript-Demonstration

Schriftsteller:Der Erfinder quantifiziert, Datum: 21.03.2023
Tags:

Die Plattform bietet native TypeScript-Unterstützung, die nur zu Beginn des Quellcodes hinzugefügt werden muss (Strategie-Sprachtyp oder JavaScript-Selektion)

// @ts-check

Sie können automatisch als TypeScript identifiziert werden.


// @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'))
}



Mehr