Static Properties

Static Properties Up to this point, we’ve only talked about the instance members of the class, those that show up on the object when it’s instantiated. We can also create static members of a class, those that are visible on the class itself rather than on the instances. In this example, we use static on the origin, as it’s a general value for all grids. Each instance accesses this value through prepending the name of the class. Similarly to prepending this. in front of instance accesses, here w

Test

Test Run the project. You should see a message when you type in the input boxes:

Templates

global-modifying-module.d.ts global-plugin.d.ts global.d.ts module-class.d.ts module-function.d.ts module-plugin.d.ts module.d.ts

String Literal Types

String Literal Types String literal types allow you to specify the exact value a string must have. In practice string literal types combine nicely with union types, type guards, and type aliases. You can use these features together to get enum-like behavior with strings. type Easing = "ease-in" | "ease-out" | "ease-in-out"; class UIElement { animate(dx: number, dy: number, easing: Easing) { if (easing === "ease-in") { // ... } else if (easing === "ease-out") { } else

Set up the server

Set up the server In project.json add another entry in "dependencies": "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final" The resulting dependencies should look like this: "dependencies": { "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final", "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final", "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final" }, Replace the body of Configure in Startup.cs with public void Configure(IApplicationBuilder app) { app.UseIISPlatformHandler(); ap

species

Symbol.species A function valued property that is the constructor function that is used to create derived objects.

Set up the build

Set up the build Right click on the project and click New Item. Then choose TypeScript Configuration File and use the default name tsconfig.json. Replace the default tsconfig.json with the following: { "compilerOptions": { "noImplicitAny": true, "noEmitOnError": true, "sourceMap": true, "target": "es5", "outDir": "./Scripts/App" }, "files": [ "./src/app.ts", ], "compileOnSave": true } This is similar to the default, with the following differences: It sets "noImplicitAny"

Splitting Across Files

Splitting Across Files As our application grows, we’ll want to split the code across multiple files to make it easier to maintain.

split

Symbol.split A regular expression method that splits a string at the indices that match the regular expression. Called by the String.prototype.split method.

Set up the build

Set up the build