Validators in a single file

Validators in a single file interface StringValidator { isAcceptable(s: string): boolean; } let lettersRegexp = /^[A-Za-z]+$/; let numberRegexp = /^[0-9]+$/; class LettersOnlyValidator implements StringValidator { isAcceptable(s: string) { return lettersRegexp.test(s); } } class ZipCodeValidator implements StringValidator { isAcceptable(s: string) { return s.length === 5 && numberRegexp.test(s); } } // Some samples to try let strings = ["Hello", "98052", "101"]; /

Test

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

Class Decorators

Class Decorators A Class Decorator is declared just before a class declaration. The class decorator is applied to the constructor of the class and can be used to observe, modify, or replace a class definition. A class decorator cannot be used in a declaration file, or in any other ambient context (such as on a declare class). The expression for the class decorator will be called as a function at runtime, with the constructor of the decorated class as its only argument. If the class decorator re

Using with export = or import

Using with export = or import An important rule is that export and import declarations export or import all meanings of their targets.

Re-export to extend

Re-export to extend Often you will need to extend functionality on a module. A common JS pattern is to augment the original object with extensions, similar to how JQuery extensions work. As we’ve mentioned before, modules do not merge like global namespace objects would. The recommended solution is to not mutate the original object, but rather export a new entity that provides the new functionality. Consider a simple calculator implementation defined in module Calculator.ts. The module also exp

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

Generics

Generics Don’t ever have a generic type which doesn’t use its type parameter. See more details in TypeScript FAQ page.

Duo

Duo

unscopables

Symbol.unscopables An Object whose own property names are property names that are excluded from the ‘with’ environment bindings of the associated objects.

gulp

gulp