当前位置:网站首页>d. TS --- for more detailed knowledge, please refer to the introduction on the official website (chapter of declaration document)
d. TS --- for more detailed knowledge, please refer to the introduction on the official website (chapter of declaration document)
2022-04-23 05:22:00 【process1212】
d.ts What is it
js File missing type ,ts So many types of data are gone , So you need a d.ts File to mark a js The type of objects in the library .
typings It's on the Internet d.ts database .
Simply speaking , Is to describe the member types in the library to give TS With .
benefits : code safety , The editor can intelligently remind
There are many more definitions export Data type of , and interface For external modules to call . Obviously, it's the data specification .
Declaration file
When using third-party libraries , You need to reference its declaration file
$('#foo');
// or
jQuery('#foo');
Use declare
Keyword to define its type , help TS Determine the incoming type :
declare var jQuery: (selector: string) => any;
jQuery('#foo');
declare
The defined type will only be used for compile time checks , The compilation result will be deleted .
Put the type declaration in a separate file , This is the declaration file .
// jQuery.d.ts
declare var jQuery: (string) => any;
Use ///
Indicates that the declaration file is referenced :
/// <reference path="./jQuery.d.ts" />
jQuery('#foo');
Index signature
Can be accessed by string js Objects in the , Save references to other objects .
版权声明
本文为[process1212]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230519445789.html
边栏推荐
- 【openh264】cmake: msopenh264-static
- (十一)vscode代码格式化配置
- Laravel implements the Holy Grail model with template inheritance
- 相机成像+单应性变换+相机标定+立体校正
- d.ts---更详细的知识还是需要看官网的介绍(声明文件章节)
- Good test data management, in the end how to do?
- node中的redis使用--ioredis
- How does PostgreSQL parse URLs
- Musk and twitter storm drama
- Three of three JS (webgl) is simple to draw lines / arcs according to points (based on linegeometry / line2 / linematerial, draw two arc segments based on the center of the circle)
猜你喜欢
Laravel [view]
SQLyog的基本使用
引入精益管理方式,需要提前做到这九点
Domain driven model DDD (III) -- using saga to manage transactions
Open source rule engine - Ice: dedicated to solving flexible and complex hard coding problems
At pgconf Asia Chinese technology forum, listen to Tencent cloud experts' in-depth understanding of database technology
数字化转型失败,有哪些原因?
Traversal of tree
2021 年 25 大 DevOps 工具(下)
Power consumption parameters of Jinbei household mute box series
随机推荐
WTL 自绘控件库 (CQsCheckComboxBox)
Output string in reverse order
Master-slave replication of MariaDB database
【openh264】cmake: msopenh264-static
Modèle axé sur le domaine DDD (III) - gestion des transactions à l'aide de Saga
Study notes: unity customsrp-12-hdr
CPT 104_TTL 09
One month countdown, pgconf What are the highlights of the latest outlook of asia2021 Asian Conference?
2022年最热门的招聘技术技能是什么,您绝对想不到
[untitled] kimpei kdboxpro's cool running lantern coexists with beauty and strength
工具在数字化转型中扮演了什么样的角色?
了解 DevOps,必读这十本书!
Open source rule engine - Ice: dedicated to solving flexible and complex hard coding problems
看板快速启动指南
To understand Devops, you must read these ten books!
4 most common automated test challenges and Countermeasures
好的测试数据管理,到底要怎么做?
2021-09-28
2021-10-08
Use of uniapp native plug-ins