当前位置:网站首页>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/
}
]
}
}
边栏推荐
- ShardingSphere之垂直分库分表实战(五)
- MySQL database advanced articles
- 【愚公系列】2022年07月 Go教学课程 013-常量、指针
- SWM32 Series Tutorial 6 - Systick and PWM
- Neural Network (ANN)
- Detailed explanation of 9 common reasons for MySQL index failure
- 加密传输过程
- 24. 请你谈谈单例模式的优缺点,注意事项,使用场景
- MySQL table design for message queue to store message data
- Preparations for web vulnerabilities
猜你喜欢
华为“天才少年”稚晖君又出新作,从零开始造“客制化”智能键盘
typescript14-(单独指定参数和返回值的类型)
(5) fastai application
Summary of MySQL database interview questions (2022 latest version)
Gabor滤波器学习笔记
【深入浅出玩转FPGA学习13-----------测试用例设计1】
Error ER_NOT_SUPPORTED_AUTH_MODE Client does not support authentication protocol requested by serv
Error occurred while trying to proxy request项目突然起不来了
DOM系列之 offset 系列
(五)fastai应用
随机推荐
typescript16-void
redis学习
Optimization of aggregate mentioned at DATA AI Summit 2022
Meeting OA project pending meeting, all meeting functions
【唐宇迪 深度学习-3D点云实战系列】学习笔记
XSS related knowledge
SereTOD2022 Track2 Code Analysis - Task-based Dialogue Systems Challenge for Semi-Supervised and Reinforcement Learning
The difference between h264 and h265 decoding
typescript13-类型别名
[In-depth and easy-to-follow FPGA learning 14----------Test case design 2]
What is Promise?What is the principle of Promise?How to use Promises?
【深入浅出玩转FPGA学习13-----------测试用例设计1】
【Yugong Series】July 2022 Go Teaching Course 017-IF of Branch Structure
unity2D横版游戏教程4-物品收集以及物理材质
MySQL notes under
Gabor filter study notes
网络常用的状态码
寄存器(汇编语言)
IOT跨平台组件设计方案
[Yugong Series] July 2022 Go Teaching Course 016-Logical Operators and Other Operators of Operators