当前位置:网站首页>Problem record in the use of TypeScript
Problem record in the use of TypeScript
2022-07-31 00:48:00 【Wild Life】
TypeScript
文章目录
元组声明BUG
let list: [string, number] = ['hello', 123];
list.push('world'); // success
// Theoretically it is not possible list add any element
setter, getter 编译需要支持 es5
# 编译成jsDocumentation is easy to execute
$ tsc app.ts
app.js
# 使用es5 compiled intojsDocumentation is easy to execute
$ tsc -t es5 app.ts
app.js
# 使用 node 执行js文件
$ node app.js
TypeScript 在 import When the file is prompted, the file does not exist
// src/main.ts
import popup from './comoonents/popup/popup';
popup({
})
然后启动 npm run serve
报错,./components/popup/popup
文件不存在.
The reason is the need to be in webpack.config.js 中添加一行配置:
moduel.exports = {
mode: 'development',
entry: './src/main.ts',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'main.js'
},
devServer: {
},
resolve: {
// 需要调整 import 文件的查找顺序,这样才能让 webapck Found while packing .ts 文件的模块
extensions: ['.ts', '.js', '.json']
},
module: {
rules: [
{
test: /\.ts$/,
use: ['ts-loader'],
// 屏蔽 node_modules 中的 .ts 文件
exclude: /node_modules/
}
]
}
}
边栏推荐
- MySQL数据库的truncate与delete区别
- MySQL系列一:账号管理与引擎
- [Tang Yudi Deep Learning-3D Point Cloud Combat Series] Study Notes
- ShardingSphere之垂直分库分表实战(五)
- DNS resolution process [visit website]
- 【唐宇迪 深度学习-3D点云实战系列】学习笔记
- Understand from the 11 common examples of judging equality of packaging types in the written test: packaging types, the principle of automatic boxing and unboxing, the timing of boxing and unboxing, a
- 【Yugong Series】July 2022 Go Teaching Course 013-Constants, Pointers
- 埃拉托斯特尼筛法
- [In-depth and easy-to-follow FPGA learning 15---------- Timing analysis basics]
猜你喜欢
随机推荐
The difference between substring and substr in MySQL
从两个易错的笔试题深入理解自增运算符
Homework: iptables prevent nmap scan and binlog
What is Promise?What is the principle of Promise?How to use Promises?
Gabor滤波器学习笔记
ShardingSphere之读写分离(八)
xss bypass: prompt(1)
MySQL master-slave replication and read-write separation script - pro test available
(5) fastai application
Neural Network (ANN)
A complete guide to avoiding pitfalls for the time-date type "yyyy-MM-dd HHmmss" in ES
[Tang Yudi Deep Learning-3D Point Cloud Combat Series] Study Notes
Shell programming of conditional statements
go mode tidy出现报错go warning “all“ matched no packages
ShardingSphere之公共表实战(七)
Adding, deleting, modifying and checking the foundation of MySQL
【深入浅出玩转FPGA学习14----------测试用例设计2】
不用Swagger,那我用啥?
Optimization of aggregate mentioned at DATA AI Summit 2022
DOM系列之动画函数封装