【问题标题】:experimentalDecorators error in typegrapqltypegrapql 中的实验装饰器错误
【发布时间】:2021-10-03 14:08:06
【问题描述】:

我目前正在学习 TypeGraphQL 并尝试创建一个基本的 reslover,我的代码如下所示:

@Resolver()
class HelloReslover {
    @Query(() => String)

    async hello(){
        return "hello wtold"
    }
}

但我得到了这个错误:

“对装饰器的实验性支持是一项受制于 在将来的版本中更改。设置 'experimentalDecorators' 选项 你的 'tsconfig' 或 'jsconfig' 来删除这个警告。”

但我的tsconfig 文件看起来像这样:

{
    "compilerOptions": {
      "target": "es6",
      "module": "commonjs",
      "lib": ["dom", "es6", "es2017", "esnext.asynciterable"],
      "sourceMap": true,
      "outDir": "./dist",
      "moduleResolution": "node",
      "declaration": false,
  
      "composite": false,
      "removeComments": true,
      "noImplicitAny": true,
      "strictNullChecks": true,
      "strictFunctionTypes": true,
      "noImplicitThis": true,
      "noUnusedLocals": true,
      "noUnusedParameters": true,
      "noImplicitReturns": true,
      "noFallthroughCasesInSwitch": true,
      "allowSyntheticDefaultImports": false,
      "emitDecoratorMetadata": true,
      "experimentalDecorators": true,
      "skipLibCheck": true,
      "baseUrl": ".",
      "rootDir": "src"
    },
    "exclude": ["node_modules"],
    "include": ["./src/**/*.tsx", "./src/**/*.ts"]
}

我该如何解决这个问题?

【问题讨论】:

  • 奇怪,能分享一下代码吗?
  • 我自己修好了,如果有人遇到同样的问题,我会分享如何

标签: node.js typescript graphql typegraphql


【解决方案1】:

我自己修好了,我是怎么做到的:

我删除了tsconfig.json 中的所有内容并将其替换为以下代码:

{
  "compilerOptions": {
    "target": "es2018",
    "module": "commonjs",
    "lib": ["es2018", "esnext.asynciterable"],
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true
  }
}

【讨论】:

    猜你喜欢
    • 2015-09-02
    • 2018-04-05
    • 2017-02-08
    • 2011-04-18
    • 1970-01-01
    • 2017-05-25
    • 1970-01-01
    • 2013-06-08
    • 1970-01-01
    相关资源
    最近更新 更多