dir.by  
  Поиск  
Компьютер, программы
TypeScript - programming language similar to JavaScript. TypeScript uses types, classes, inheritance. TypeScript converted to JavaScript
 Compilation settings Typescript in Javascript At the command prompt: removeComments, outFile, outDir 
посмотрели 7647 раз
обновлено: 2 March 2020
Настройки компиляции
Описание
Варианты
Примеры
--target "версия"
or
--t "версия"
Версия Javascript.

То есть Typescript компилируется в версию Javascript.
--t "ES3"
--t "ES5"
--t "ES6"/"ES2015"
--t "ES2016"
--t "ES2017"
--t "ES2018"
--t "ES2019"
--t "ES2020"
--t "ESNext"

На заметку! "ESNext" это последняя Javascript версия поддерживаемая на вашем компьютере
Файл app.ts
  TypeScript  
class Book
{
     name : string;
     price : number;

     constructor(_name : string, _price : number)
     {
          this.name = _name;
          this.price = _price;
     }
}




Пример 1. указываем последнюю версию ESNext
  Command Prompt (Win Console)  
tsc app.ts --t "ESNext"


Файл app.ts компилируется в
файл app.js:
  JavaScript  
class Book {

     constructor(_name, _price) {
          this.name = _name;
          this.price = _price;
     }

}




Пример 2. не указываем версию, то есть по умолчанию это ES3
  Command Prompt (Win Console)  
tsc app.ts


Файл app.ts компилируется в
файл app.js:
  JavaScript  
var Book = (function () {

     function Book(_name, _price) {
          this.name = _name;
          this.price = _price;
     }

return Book;

}());
--removeComments
Удаление комментариев
 
← Previous topic
Create a new application with TypeScript (compile in the command line TypeScript in JavaScript)
 
Next topic →
Create a new application TypeScript in Visual Studio Code. Debug the application. We look in debugging how TypeScript is executed step by step. Breakpoints.
 
Your feedback ... Comments ...
   
Your Name
Your comment (www links can only be added by a logged-in user)

  Объявления  
  Объявления  
 
What the TypeScript ?
How to download, install TypeScript ? How to check what is installed TypeScript and which version?
New app
Option 1. Write the application in a text editor, compile it on the command line
Create a new application with TypeScript (compile in the command line TypeScript in JavaScript)
Compilation settings Typescript in Javascript At the command prompt: removeComments, outFile, outDir
Option 2 [bgcolor=lightblue](best for me)[/bgcolor]. Writing the application in Visual Studio Code
Create a new application TypeScript in Visual Studio Code. Debug the application. We look in debugging how TypeScript is executed step by step. Breakpoints.
Create a new TypeScript app in Visual Studio Code. I"ve created some ts files. That"s why I use Webpack (collects all files into one js). Debug is running and Breakpoints are set.
Option 3. Writing an application in Visual Studio 2017
Create a new Node.js console app in Visual Studio 2017 to learn Typescript
TypeScript Features
A decorator for a class in TypeScript. Example: @MyDecarator1 class Book {...}
Convert class to {property object}. Typescript. Example: var myProps1 = {... myClass1};
WWW sites to explore TypeScript
Sites to explore TypeScript

  Ваши вопросы присылайте по почте: info@dir.by