
Typescript is a scripting language compiled into JavaScript. The development of Microsoft, which, to date, has managed to win and fans and detractors. The main question for beginners, and not only: "Why do I need him?".
Since the articles describing the advantages and disadvantages, the description of the language and examples of the work - shaft, I would like to describe the practical conclusions when working in a fairly large application.
Let's start with the main advantages:
')
- Strong typing
- Code readability
- Easier transition from the world of strict typing, rather than directly into JavaScript, in which Dynamics rules
- JavaScript backward compatibility
- Broad IDE support
Strong typing
Allows you to more fully describe the properties and methods of objects and classes, which is why there is no need, which, personally, I was wildly annoyed to do a check of all the arguments included in the method or function:
function checkAllMyArgsAgain(check, me, please) {
if(check && me && please) {
if(check instanceof CheckObject){
console.log('!');
} else {
console.log(' ...')
}
if(me){ } // .......
}
}
, TypeScript :
function checkAllMyArgsAgain(check: CheckObject, me: MeObject, please: string): string {
return ' ? ? ';
}
, :
, , TypeScript , , Javascript.
, , JavaScript, - …
function checkMe(check, me) {
if(check && me) {
if(check){ ... }
if(me){ ... }
}
}
function andCheckMe(check, me) {
if(check && me) {
if(check){ ... }
if(me){ ... }
}
}
function andCheckMeToo(check, me) {
if(check && me) {
if(check){ ... }
if(me){ ... }
}
}
:
function checkMe(check: CheckObject, me: MeObject) {
console.log(' !');
}
function andCheckMe(check: CheckObject, me: MeObject) {
console.log(' ');
}
function andCheckMeToo(check: CheckObject, me: MeObject) {
console.log(' ');
}
, JS, , , TS .
JS
JS, . TS, JS, .
JS
, , , , TS + JS TS, .
IDE
TypeScript, , IDE, IDEA, WebStorm, Sublime, Atom, . , .
:
- Debug
- ?
, , , , , , JavaScript .
— JS TS. , .d.ts , . , , jQuery, .
«» , , , , JS, .
, , , , , , , , .
Debug
, , , , , . , , , TypeScript. IDE:
WebStorm Visual Studio , , JS , , , . TS .
?
, JS , TS: , , . , TS TS . Microsoft , TS open-source? , , TS — , , Microsoft, .
Microsoft, , , : Skype, Nokia, Windows Phone, Windows Vista, .
, - , .
, !