当前位置:网站首页>TypeScript 的组件
TypeScript 的组件
2022-07-31 22:11:00 【华为云】
TypeScript 语言在内部分为三个主要层。这些层中的每一层都分为子层或组件。在下图中,我们可以看到三层及其内部组件。这些层是:
Language
TypeScript 编译器
TypeScript 语言服务
1. Language
它具有 TypeScript 语言元素。它包含语法、关键字和类型注释等元素。
2. TypeScript 编译器
TypeScript 编译器 (TSC) 将 TypeScript 程序转换为其 JavaScript 代码。它还执行我们的 TypeScript 代码到 JavaScript 代码的解析和类型检查。
浏览器不支持直接执行 TypeScript 代码。所以用 TypeScript 编写的程序必须用 JavaScript 等效代码重写,它支持直接在浏览器中执行代码。为此,TypeScript 附带了名为“tsc”的 TypeScript 编译器。当前版本的 TypeScript 编译器默认支持 ES6。它编译任何模块中的源代码,如 ES6、SystemJS、AMD 等。
我们可以通过本地、全局或同时使用任何npm包安装 TypeScript 编译器。安装完成后,我们可以通过在命令行上运行“tsc”命令来编译 TypeScript 文件。
##起步安装 npm install typescript -g
例子:
tsc helloworld.ts // 它将 TS 文件 helloworld 编译成 helloworld.js 文件。
编译器配置
TypeScript 编译器配置在tsconfig.json文件中给出,如下所示:
{ "compilerOptions": { "declaration": true, "emitDecoratorMetadata": false, "experimentalDecorators": false, "module": "none", "moduleResolution": "node", "noFallthroughCasesInSwitch": false, "noImplicitAny": false, "noImplicitReturns": false, "removeComments": false, "sourceMap": false, "strictNullChecks": false, "target": "es3" }, "compileOnSave": true }
3. TypeScript 语言服务
边栏推荐
- Financial profitability and solvency indicators
- Basic configuration of OSPFv3
- Several methods of mysql backup table
- Dry goods | 10 tips for MySQL add, delete, change query performance optimization
- Bionic caterpillar robot source code
- "APIO2010" Patrol Problem Solution
- STM32 full series development firmware installation guide under Arduino framework
- Socket回顾与I/0模型
- spark reports an error OutOfMemory "recommended collection"
- 支付模块实现
猜你喜欢
二叉树非递归遍历
VOT2021 game introduction
What's wrong with the sql syntax in my sql
Dry goods | 10 tips for MySQL add, delete, change query performance optimization
ReentrantLock原理(未完待续)
Collation of knowledge points in Ningbo University NBU IT project management final exam
The difference between adding or not adding the ref keyword when a variable of reference type is used as a parameter in a method call in C#
Daily practice——Randomly generate an integer between 1-100 and see how many times you can guess.Requirements: The number of guesses cannot exceed 7 times, and after each guess, it will prompt "bigger"
Bionic caterpillar robot source code
利用反射实现一个管理对象信息的简单框架
随机推荐
NVIDIA has begun testing graphics products with AD106 and AD107 GPU cores
统计UTF-8字符串中的字符函数
JS basic exercises
Quick Start Tutorial for flyway
How to debug TestCafe
每月一书(202207):《Swift编程权威指南》
Go1.18 upgrade function - Fuzz test from scratch in Go language
A few permanent free network transmission, convenient and simple (Intranet through tutorials)
一款国外开发的高质量WordPress下载站模板主题
Several methods for deleting specified elements in Golang slices
Golang must know the Go Mod command
【论文精读】iNeRF
Pytest first experience
Collation of knowledge points in Ningbo University NBU IT project management final exam
How to get useragent
C#中引用类型的变量做为参数在方法调用时加不加 ref 关键字的不同之处
基于RT1052 Aworks nanopb string 类型固定长度使用方式(二十七)
The principle of ReentrantLock (to be continued)
支付模块实现
"SDOI2016" Journey Problem Solution