我在尝试使用 RESTDataSource 时开始出现错误:
"Class constructor RESTDataSource cannot be invoked without 'new'"
所以我尝试了这个解决方案并添加了"target": "es2016"
. 我不再收到错误消息。
但现在我收到打字稿编译错误
error TS2451: Cannot redeclare block-scoped variable 'Query'.
显然这是因为打字稿无法将我的文件识别为模块。
所以我尝试了这个解决方案并将其添加export {}
到我的文件中,以便它们被识别为模块。但是因为我的目标是es2016
我得到Unexpected token 'export'
有什么办法可以同时解决这两个问题?
错误发生在我的代码中,所以我将包括整个回购:https ://github.com/grochadc/filex-graphql-server
tsconfig.json
{
"compilerOptions": {
"target": "es2016",
"moduleResolution": "node",
"outDir": "dist/",
"allowSyntheticDefaultImports": true
},
"include": ["src/"],
"exclude": ["node_modules", "**/*.spec.ts"]
}