【发布时间】:2017-05-14 06:24:31
【问题描述】:
首先 - 不是 Using of TypeScript decorators caused errors 的重复项,因为我在 tsconfing.json 中使用了 "experimentalDecorators" : true 并且没有帮助,这可能是 WebStorm 问题。
所以我使用 Mobx 并尝试使用它的装饰器,我得到了这个错误(这是直截了当的):
问题是,我在项目根目录下的 tsconfig 已经有了这个,这是我的 tsconfig 文件:
{
"compilerOptions": {
"experimentalDecorators": true,
"outDir": "./dist/",
"sourceMap": true,
"noImplicitAny": false,
"module": "commonjs",
"moduleResolution": "node",
"target": "es5",
"jsx": "react",
"lib": ["dom", "es2016"],
"types": ["mocha", "chai", "node", "protractor"]
},
"include": [
"./test/matchers/custom.matchers.d.ts",
"./test/**/*.ts"
],
"files": [
"./src/external-types.d.ts",
"./src/app.tsx"
]
}
我错过了什么?为什么 WebStorm 总是在每个装饰器上显示这个错误?
【问题讨论】:
-
你的form-store.ts文件在
./test/目录下吗?使用这两个文件并包含在 tsconfig.json 中是否有效?文档似乎暗示它是其中之一:typescriptlang.org/docs/handbook/tsconfig-json.html -
@JBNizet 它不在测试目录下,一般其他一切正常,只是装饰器有问题
-
那么您的 tsconfig.json 不适用于此文件,因为它不包含在内。
-
@JBNizet 你是对的......我错过了,请发布答案,以便我接受并投票:)
标签: typescript webstorm