dir.by  
  Search  
Programming, development, testing
TypeScript - programming language similar to JavaScript. TypeScript uses types, classes, inheritance. TypeScript converted to JavaScript
Create a new application with TypeScript (compile in the command line TypeScript in JavaScript)
  Looked at 4845 times    
 Create a new application with TypeScript (compile in the command line TypeScript in JavaScript) 
last updated: 2 March 2020
Step 1. Creating files
  Html     Create a new file 1.html and write the code:
File 1.html Download
<html>
<head>
     <meta charset="utf-8" />
</head>

<body>

     <!-- include js script -->
     <script src="app.js" ></script>

     <!-- my script -->
     <script>
          var book1 = new Book("Count of Montecristo", 40);
          alert(book1.name + " " + book1.price);
     </script>

</body>
</html>
  TypeScript     Create a new file app.ts and write the code:
File app.ts Download
class Book
{
     name : string;
     price : number;

     constructor(newName: string, newPrice: number)
     {
          this.name = newName;
          this.price = newPrice;
     }
}
Step 2. Compiling the file .ts to file .js
run in the command line:
  Command Prompt (Win Console)  
tsc app.ts


Note!
It happens that the command does not work tsc
Therefore, look for the file tsc.exe and run at the command prompt:
  Command Prompt (Win Console)  
"C:/Program Files (x86)/Microsoft SDKs/TypeScript/3.1/tsc.exe" app.ts
Step 3. Run 1.html
 
← Previous topic
How to download, install TypeScript ? How to check what is installed TypeScript and which version?
 
Next topic →
Compilation settings Typescript in Javascript At the command prompt: removeComments, outFile, outDir
 
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?
Новое приложение
Вариант 1. Приложение пишем в текстовом редакторе, компилируем в командной строке
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
Вариант 2 (для меня лучший). Приложение пишем в 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.
Создаем новое приложение с TypeScript в Visual Studio Code. Я создал несколько ts файлов. Поэтому использую Webpack (собирает все файлы в один js). Работает отладка (Debug) и ставятся точки остановки Breakpoints.
Вариант 3. Приложение пишем в Visual Studio 2017
Создаем новое Node.js консольное приложение в Visual Studio 2017 для изучения Typescript
Возможности TypeScript
Decorator for the classroom in the TypeScript. Пример: @MyDecarator1 class Book {...}
Конвертируем class в {объект свойств}. Typescript. Пример: var myProps1 = {...myClass1};
WWW sites to explore TypeScript
Sites to explore TypeScript

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