From IT Skills
Jump to: navigation, search

TypeScript restricts JavaScript, which means that not everything possible within JavaScript is possible in TypeScript, sometimes deliberately.

Understanding TypeScript - для швидкого ознайомлення

TypeScript как будущее энтерпрайзного JavaScript

Visual Studio[edit]

підтримка в студіях новіше 2012

Angular#2 tsconfig.json is not supported in VS 2013. and there are no plans to add support for it in the future. VS 2015 does have that


  • the only purpose for TypeScript is to make order with Java-scripts mess
  • to preserve Client-Server model and to exploit TypeScript effectively enums, entity classes, interfaces etc must be actually managed in C# but TypeScript imports them and #Reuse C# definitions


TypeScript is just Javascript subset and like all Java-scripts is open sourced for anybody. All sources will go out possession by simple the "File/Save page as..." menu.


Microsoft Coding-guidelines codelyzer

Module and Namespace[edit]

!!! use either Namespaces that tend to gather ts-files into ONE js or ONLY modules. Do not mix namespaces and modules in new applications!

anywhere the module keyword was used when declaring an internal module, the namespace keyword can and should be used instead


!! I have problems. It is compiled but does not work

no import is needed

Just like all global namespace pollution, it can be hard to identify component dependencies, especially in a large application.

External Module[edit]

A key feature of modules in TypeScript is that two different modules will never contribute names to the same scope.

Global, File (also called external module)

import moduleName = require("moduleFile") or import * as moduleName from "moduleFile";

and better

import {moduleName} from 'moduleFile'


import polygons = Shapes.Polygons;

Do not use namespaces in modules[edit]

When first moving to a module-based organization, a common tendency is to wrap exports in an additional layer of namespaces. Modules have their own scope, and only exported declarations are visible from outside the module. With this in mind, namespace provide very little, if any, value when working with modules.

however namespaces are good for global modules.


The JavaScript language doesn't have interfaces. Angular can't see TypeScript interfaces at runtime because they disappear from the transpiled JavaScript.


In TypeScript, each member is public by default.

Однако в ES6 нам доступен вызов объекта WeakMap, который позволяет создавать приватные свойства.

Inheritance in JS[edit]

Mixins - this is multiple inheritance



The TypeScript support for the prototype of the ES7 Reflection API.

Reflect in ES7.

  • angular team does not use npm reflect-metadata

How get class name in runtime[edit]

  1. !!! type-guards

  1. by obj.prototype.constructor.toString() works until code is not minified-uglified and does not work in AOT decorators
    customize uglifying to preserve class names but result size may become 5% larger
  2. to add manually class name as property value like (best of all as partial file that is not implemented yet)
    export class Dashboard {
        static class = 'Dashboard';
    • or add manually class name as decorator value and use package like reflect-metadata
  3. interfere in Typescript transpilation and generate property value with class name automatically

transform plain javascript object to the ES6 classes[edit]

Reuse C# definitions[edit]

CSharp to JS migration[edit]

but in reality reused classes will get properties (...a: number;...) that are impossible to override because get and set should be used (...get a(){return this._a} set a(value){this._a=value}...), so these reused classes are usefull as interfaces


Getting type declarations in TypeScript 2.0 will require no tools apart from npm. search at



  • module Specify module code generation: ‘CommonJS’, ‘amd’, ‘system’, ‘umd’, or ‘es2015’. Only ‘amd’ and ‘system’ can be used in conjunction with --outFile. The ‘es2015’ value may not be used when targeting ES5 or lower.

formats used in #System.config\packages\...\format


The packages node tells SystemJS what to do when it sees a request for a module from the app/ folder.