TypeScript is an open-source programming language developed and maintained by Microsoft.
Every JavaScript program is also a TypeScript program. It is a strict syntactical superset of JavaScript with design-time support for type safety and tooling. TypeScript adds optional types, classes, and modules to JavaScript.
TypeScript is designed for development of large applications and transpile to JavaScript
Browsers can't execute TypeScript directly. Typescript must be "transpiled" into JavaScript using the tsc compiler, which requires some configuration. The TypeScript compiler is itself written in TypeScript and compiled to JavaScript.
The TypeScript compiler performs only file local transformations on TypeScript programs and does not re-order variables declared in TypeScript. This leads to JavaScript output that closely matches the TypeScript input. TypeScript does not transform variable names, making tractable the direct debugging of emitted JavaScript. TypeScript optionally provides source maps, enabling source-level debugging. TypeScript tools typically emit JavaScript upon file save, preserving the test, edit, refresh cycle commonly used in JavaScript development.
TypeScript compiles to clean, simple JavaScript code which runs on any browser, in Node.js, or in any JavaScript engine that supports ECMAScript 3 (or newer).
TypeScript is designed for development of large applications and transpile to JavaScript
TypeScript is a primary language for Angular application development.
Browsers can't execute TypeScript directly. Typescript must be "transpiled" into JavaScript using the tsc compiler, which requires some configuration. The TypeScript compiler is itself written in TypeScript and compiled to JavaScript.
Installing
For the latest stable version: npm install -g typescript
For the latest stable version: npm install -g typescript
Building your first TypeScript file
In your editor, type the following JavaScript code in
greeter.ts
:Compiling your code
We used a
.ts
extension, but this code is just JavaScript. You could have copy/pasted this straight out of an existing JavaScript app.
At the command line, run the TypeScript compiler:
The result will be a file
greeter.js
which contains the same JavaScript that you fed in. We’re up and running using TypeScript in our JavaScript app!Running your TypeScript web app
Now type the following in
greeter.html
:
Open
greeter.html
in the browser to run your first simple TypeScript web application!
No comments:
Post a Comment