当前位置:网站首页>Type description file of module code
Type description file of module code
2022-04-22 18:46:00 【Xiao Er Li】
This article will introduce TypeScript Knowledge about the type description file of module code in .
npm install jquery library .
cnpm i jquery -S
stay ts Introduce in the file jquery The following information will be prompted when the library

Create a new type description file jquery.d.ts, Used for definition ts Used in the file jquery Module definition .
jquery.d.ts
// ES6 modularization : The definition is jquery Module
declare module 'jquery' {
// The definition is $, The parameter is a function type , The return value is void Function of
function $(readyFunc: () => void): void;
// The definition is $, Parameter is string, It contains a receiver string Parameters , The return value is void Function of
function $(selector: string): {
html: (html: string) => void;
}
// Namespace
namespace $ {
namespace fn {
class init{}
}
}
// Export custom functions
export = $;
}
At this time ts It can be identified in the document jquery Module , You can also use the global functions and namespaces defined in the module .
demo.ts
import $ from 'jquery';
$(function () {
$('body').html('<div>123</div>')
new $.fn.init()
})
版权声明
本文为[Xiao Er Li]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204221841308661.html
边栏推荐
猜你喜欢

华为云媒体査勇:华为云在视频AI转码领域的技术实践

浅析局域网聊天软件的能力

The Sandbox 与 Slipknot 以及 Knotfest 达成合作关系,共同打造 KNOTVERSE

DL之YoloV3:YoloV3论文《YOLOv3: An Incremental Improvement》的翻译与解读

旅游产品分析:要出发周边游

【全网最全】JSR303参数校验与全局异常处理(从理论到实践别用if判断参数了)

花样机模板电脑CAD免费打板转格式软件PS300B使用步骤教程:日本兄弟牌Brother花样机通用CAD画图打板.dxf文件转.emb文件

人气种草产品预测,猜中TOP 3得红包!
![[fundamentals of interface testing] Chapter 11 | detailed explanation of postman associated interface and batch execution use case set](/img/e6/33b1cd576b08a5eb9ff455c20107ad.png)
[fundamentals of interface testing] Chapter 11 | detailed explanation of postman associated interface and batch execution use case set

微星小飞机 性能监控设置
随机推荐
WiFi技术概述:WiFi那些事
力扣-64.最小路径和
视频知识点(16)- 如何将y4m文件转换成yuv文件?
Jsonobject data guarantee order of fastjson
跨链资产交互——如何在Moonriver上转移KSM
C# 将OFD转为PDF
[extensive reading of papers] eating embedded learning by comprehensive transcription of heterogeneous information networks
Transformation operator
SegAttnGAN Text to Image Generation with Segmentation Attention
.net core 中配置文件映射到类
stream演示
在 Kubernetes 集群中部署现代应用的通用模式
聊聊缓存布尔值踩到的坑
JVM composition
JVM专题(十二)-垃圾回收(三)
高并发之——深度解析ScheduledThreadPoolExecutor类的源代码
【CIcadplayer】进度条回调
【服务器数据恢复】服务器进水导致多块硬盘同时掉线,服务器崩溃的数据恢复案例
100 days of code-day26
Do you know how many sensors are on your phone?