我想不通的是如何让 TS 正确编译它。我的项目中没有出现任何语法错误,但是:
let imageFileId = (await db.query(sql`select id from image_files where sha256=${sha256}`))[0]?.id;
正在输出为:
let imageFileId = (await db.query(mysql3_1.sql `select id from image_files where sha256=${sha256}`))[0]?.id;
在我们获得 Node.js 的原生支持之前,它不会运行。
这是我的 tsconfig:
{
"compilerOptions": {
"strict": true,
"importHelpers": false,
"inlineSources": true,
"noEmitOnError": true,
"pretty": true,
"module": "commonjs",
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": false,
"removeComments": false,
"preserveConstEnums": false,
"sourceMap": true,
"lib": ["es2018"],
"skipLibCheck": false,
"outDir": "dist",
"target": "esnext",
"declaration": false,
"resolveJsonModule": true,
"esModuleInterop": false,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"baseUrl": ".",
"paths": {
"*": ["src/*"]
},
"noEmit": false
},
"files": [
"src/index"
],
"include": [
"src/**/*.d.ts"
]
}
我需要启用其他选项来编译?.
运算符吗?
请注意我没有使用 Babel,我不想把它带入图片中。