当前位置:网站首页>TypeScript-头文件使用细节
TypeScript-头文件使用细节
2022-06-11 07:54:00 【YY小怪兽】
1.使用别人编写好的头文件细节
安装好别人编写好的头文件之后 @type/xxx
- 如果是使用ES Module导出, 那么使用ES Module导入
- 如果是使用Node Module导出, 那么使用Node Module导入
- 如果是使用TS Module导出, 那么使用TS Module导入, 但是也可以使用ES Module或者Node Module导入
2.查看文件是什么导出
ctrl+鼠标点击导入的文件点击*.d.ts
3.ES6模块
3.1分开导入导出
export xxx;
import {
xxx} from "path";
3.2一次性导入导出
export {
xxx, yyy, zzz};
import {
xxx, yyy, zzz} from "path";
3.3默认导入导出
export default xxx;
import xxx from "path";
4.Node模块
2.1通过exports.xxx = xxx导出
通过const xxx = require("path");导入
通过const {
xx, xx} = require("path");导入
4.2通过module.exports.xxx = xxx导出
通过const xxx = require("path");导入
通过const {
xx, xx} = require("path");导入
5.ES6的模块和Node的模块是不兼容的, 所以TS为了兼容两者就推出了
export = xxx;
import xxx = require('path');
如果导出 是TS模块的话,可以使用三种方法导入
// const Koa = require('koa');//通过Node Module导入
// import Koa from 'koa'//通过ES Module导入
import Koa = require('koa')//通过TS Module导入
边栏推荐
- Servlet
- 【IoT】项目管理:如何打造更好的跨职能团队?
- [cluster] haproxy load balancing
- 代码设置ConstraintLayout的layout_constraintDimensionRatio
- TiDB Cloud 上線 Google Cloud Marketplace,以全新一棧式實時 HTAP 數據庫賦能全球開發者
- [atcoder2305] declining (game)
- [atcoder1984] wide swap
- [atcoder1981] short diameter (graph theory thinking)
- [atcoder1998] stamp Rally
- Summary of evaluation index knowledge points in target detection: summary of IOU cross overlap unit and map/ap/tp/fp/np
猜你喜欢

Zero foundation self-study SQL course | union joint query

Collation of basic knowledge of intermediate development of Andrews (for interview)

C wechat upload form data

3年功能测试拿8K,被新来的反超,其实你在假装努力

C language Yanghui triangle code

You got 8K in the 3-year function test, but you were actually pretending to work hard

Batch splice string

Use of wordcloud

Bladed入门教程(视频)

2022.6.7 special student simulation
随机推荐
Flask页面的分页
wordcloud的使用
Bidirectional linked list simple template (pointer version)
Servlet
2021-11-05 definition of cache
【集群】haproxy负载均衡
Storage of floating point in memory
Getting started with bladed tutorial (video)
[poj3691] DNA repair (AC automata +dp)
记一次忽略@SuppressLint(“NewApi“)提示引发的血案
空间几何
2021-10-17
Tutoriel de démarrage bladed (vidéo)
860. 柠檬水找零
Image data enhancement (translation, rotation, brightness transformation, flipping, adding Gaussian noise, scaling, cropping)
Xshell7 和 Xftp7要继续使用此程序,您必须应用最新的更新或者使用新版本
C language - Growth Diary -03- function definition and function prototype declaration
Uoj 551 [unr 4] campus stroll [good polynomial questions (FOG)]
【 史上最全的ENSP【安装图解】!】
[atcoder1984] wide swap