当前位置:网站首页>Typescript type declaration file (III)
Typescript type declaration file (III)
2022-06-12 18:03:00 【Out of the autistic bird】
List of articles
TS Type declaration file
Type declaration file Overview
In the project TS Will eventually be compiled into JS, When we use external third-party libraries , How to use TS Grammar .
Type declaration file : Used for existing JS The library provides type information
TS file type
- .ts file
- Contains both type information and executable code
- Can be compiled as js file , Then execute the code
- purpose : Where the program code is written
- .d.ts file
- A type declaration file that contains only type information
- Will not generate js file , Only used to provide type information
- purpose : by JS Provide type information
If you want to JS The library provides type information , You use .d.ts file
Use an existing type declaration file
Built in API Type declaration file
windows The system presses ctrl Key click built in API To open the file


Use the type declaration file of the third-party library
- The type declaration file comes with downloading the library
- from DefinitelyTyped Provide
stay TypeScript Search and download on the official website
Create your own type declaration file
Shared classes within the project
If more than one ts All files use the same type , You can create .d.ts The file provides this type , Implement type sharing
- establish index.d.ts Type declaration file
- Create a type that needs to be shared , Use export export
- Use through import Import , Omit .d.ts
For what is JS The file provides a type declaration
Importing a js When you file ,TS Automatically loaded on js The document has the same name .d.ts file
Use declare keyword : Used for type declaration , by js The variable declaration type already exists in the file , Instead of creating a new variable
// .js file
let count = 1
// .d.ts file
declare let count: number
about type、interface these TS Peculiar , You can omit declare; about let、function etc. JS and TS Can be used , You should use declare keyword
边栏推荐
- 轻量、便捷的小程序转App技术方案,实现与微信/流量App互联互通
- JDBC quick start tutorial
- C operation database added business data value content case school table
- 01-复杂度
- Variable of C #
- Introduction to reinforcement learning and analysis of classic items 1.3
- 迄今微软不同时期发布的SQL Server各版本之间的大致区别,供参考查阅
- Use the official go Library of mongodb to operate the original mongodb
- General differences between SQL server versions released by Microsoft in different periods so far, for reference
- vant3+ts h5页面嵌套进app 与原生app通信
猜你喜欢

A method of quickly reusing wechat login authorization in app

js两数之和

NixOS 22.05安装过程记录

"Big fat • small lesson" - talk about big file segmentation and breakpoint sequel

有源差分晶振原理图以及LV-PECL、LVDS、HCSL区别

极限编程--根源分析实践

机器学习系列(5):朴素贝叶斯

TypeScript类型声明文件(三)

C brief introduction

MYSQL:Expression #4 of SELECT list is not in GROUP BY clause and contains nonaggregated column
随机推荐
認識函數原創
Eve-ng installation (network device simulator)
Relationship between resolution and line field synchronization signal
关于数据集
JS中的字符串(含leetcode例题)<持续更新~>
Project training of Software College of Shandong University - Innovation Training - network attack and defense shooting range experimental platform of Software College of Shandong University (XXV) - p
Lambda - 1
有源差分晶振原理圖以及LV-PECL、LVDS、HCSL區別
Write a select based concurrent server
TypeScript常用类型(一)
vant3 +ts 封装简易step进步器组件
Gossip about the 88 of redis source code
Use applet to quickly generate app in seven steps
Sqlserver common statements and functions
PHP implementation of infinite classification tree (recursion and Optimization)
USB转串口那些事儿—串口驱动类型
JS sum of two numbers
机器学习系列(3):Logistic回归
C business serial number rule generation component
利用小程序快速生成App,只需七步