JS转TS的导包处理
在package.json加入
"type":"module"
导入语句修改为
import { xx} from "xx" import * as fs from "xx"
在javascript中类型脚本,如果在外部使用import语句就需要使"type":"module",单在类型脚本中实际是不需要,需要的是运行,在类型脚本中yarn
最好在vscode终端输入
yarn add typescript ts-node
在运行
ts-node xx.ts
参考博客
https://www.cnblogs.com/lishanlei/p/9327646.html
https://blog.csdn.net/baidu_41604826/article/details/121012285