打字稿错误-TS2339:类型“ y”上不存在属性“ x”

时间:2019-05-20 21:58:06

标签: typescript

我正在创建一个打字稿服务器,并使用ts-node在本地运行它,除非我错误地得到了TS2339错误。我在Session上遇到所有班级成员的错误。我怀疑这与tsconfig.json有关,但需要帮助。

我在SO上发现了一个非常相似的问题,但是它没有提供任何有用的信息,也没有解决问题。 link

//imports for brevity

export class Session {
  creator: User
  emailer: Emailer
  pubsub: Pubsub

  constructor(creator: User, emailer: Emailer, pubsub: Pubsub) {
    this.creator = creator
    this.emailer = emailer
    this.pubsub = pubsub
  }

  //methods for brevity
}
{
    "compilerOptions": {
        "target": "es6",
        "module": "commonjs",
        "pretty": true,
        "sourceMap": false,
        "outDir": "dist",
        "importHelpers": true,
        "strict": true,
        "noImplicitAny": false,
        "strictNullChecks": false,
        "noImplicitThis": false,
        "alwaysStrict": true,
        "noUnusedLocals": true,
        "noUnusedParameters": false,
        "noImplicitReturns": false,
        "noFallthroughCasesInSwitch": true,
        "moduleResolution": "node",
        "baseUrl": ".",
        "experimentalDecorators": true,
        "emitDecoratorMetadata": true,
        "resolveJsonModule": true,
        "esModuleInterop": true,
        "lib": [
            "es5",
            "es6",
            "dom",
            "es2015.core",
            "es2015.collection",
            "es2015.generator",
            "es2015.iterable",
            "es2015.promise",
            "es2015.proxy",
            "es2015.reflect",
            "es2015.symbol",
            "es2015.symbol.wellknown",
            "esnext.asynciterable"
        ]
    }
}

根据编译器,我没有类成员creator,emailer或pubsub,但实际上是这样。我收到类似error TS2339 Property 'creator' does not exist on type 'Session'的错误,但这似乎不正确。

0 个答案:

没有答案