function test () { var gs = new Greeter (' SS '); Alert (Gs.greet ());} Window.onload = Test;class Greeter { greeting:string; Constructor (message:string) { this.greeting = message; } Greet () { return "Hello," + this.greeting; }}
Because JSON serialization interaction is often used in the background and foreground, it can be very handy if the background-defined model can be used in the foreground, and smart hints and type checking are also very good features.
In the duplicated component, modularity needs to be constantly changing today maintainability is important and useful
Let's look at the JS that it generates
function test () { var gs = new Greeter (' SS '); Alert (Gs.greet ());} Window.onload = Test;var Greeter = (function () { //constructor function function Greeter (message) { this.greeting = message; } Greeter.prototype.greet = function () { return "Hello," + this.greeting; }; return Greeter;} ());//# Sourcemappingurl=file1.js.map
Type check variable check smart hints
Using typescript to develop JS code to improve code maintainability