typescript

https://www.tslang.cn/docs/handbook/basic-types.html;

使用Typescript开发Vue,一切准备就绪。但npm start 时,提示“

ERROR in ./src/main.ts
Module build failed: TypeError: Cannot read property 'afterCompile' of undefined“错误。

解决方法

将ts-loader从4.0降低到3.1.1解决问题。是由于webpack和ts-loader版本不兼容造成的。

来源--https://blog.csdn.net/nzyalj/article/details/78306435?locationNum=9&fps=1

3.typescript import模块的时候找不到省略.ts后缀的文件,此时在webpack.config.js中添加resolve

resolve: {
extensions: ['.ts', '.tsx','.js','.jsx'] ,
modules: ['src' ,'node_modules'],
},
4.在vscode 中用typescript开发node的时候,打开launch.json,按下ctrl +shift+b,然后选择生成任务的设置图标就会生成tasks.json,在这个任务配置文件中,可以设置
执行launch命令前的命令配置如下:
launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch TypeScript",
"program": "${workspaceRoot}/dist/server.js",
"preLaunchTask": "compile",
}
]
}
tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "compile",
"command": "gulp",
"type": "shell"
}
]
}
 
原文地址:https://www.cnblogs.com/feixiangsnail15-12-28/p/8629893.html