当前位置:网站首页>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导入
边栏推荐
- Zero foundation self-study SQL course | outer join external connection
- 使用特殊字符拼接字符串“+“
- Summary of force deduction questions
- 记一次忽略@SuppressLint(“NewApi“)提示引发的血案
- Collation of basic knowledge of intermediate development of Andrews (for interview)
- Understanding of Poisson distribution and Poisson process and Erlang distribution and their relations (important theories in queuing theory and operational research)
- 避免list的并发修改异常的几种方式
- 2022.6.6 extra long growth simulation
- Bubble sorting with C language
- [atcoder1998] stamp Rally
猜你喜欢

C- print 99 multiplication table

Bladed入門教程(視頻)

mpi

TiDB Cloud 上线 Google Cloud Marketplace,以全新一栈式实时 HTAP 数据库赋能全球开发者

Batch splice string

How to prepare for the new PMP syllabus exam?
![[atcoder1980] mystious light (mathematical simulation)](/img/c0/7de31b36e11ff71328d927c1d1c2d3.png)
[atcoder1980] mystious light (mathematical simulation)

C language to achieve three piece chess (not artificial mental retardation ha ha ha)

学习《缠解论语》

Flask页面的分页
随机推荐
【集群】haproxy负载均衡
Activity中,View#postDelay会导致内存泄漏,但是不会影响Activity的生命周期执行。
How to prepare for the new PMP syllabus exam?
Collation of basic knowledge of intermediate development of Andrews (for interview)
Import on CSDN MD file
2021-10-17
Simple use of string
Note: JDBC
What exactly is PMP?
Bladed入门教程(视频)
Classes and objects (Part 2)
Crawl Baidu Baipin dynamic page
2021-11-05 definition of cache
C language to achieve three piece chess (not artificial mental retardation ha ha ha)
【AtCoder2304】Cleaning
如何做好空状态设计?来看这份全面总结
Socket [5] - struct linker usage
使用特殊字符拼接字符串“+“
SOCKET【5】- struct linger 用法
Sort - merge sort