dir.by  
  Поиск  
Компьютер, программы
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) 
посмотрели 8555 раз
обновлено: 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?
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