错误说明
vscode code runner 插件执行ts报错
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for
解决方案
tsconfig.json
{
...
"ts-node": {
// Tell ts-node CLI to install the --loader automatically, explained below
"esm": true
}
...
}
扩展
快速生成tsconfig.json文件
tsc --init
参考资料
CommonJS vs native ECMAScript modules | ts-node (typestrong.org)