对装饰器的实验性支持是一个在将来的版本中可能会发生变化的功能

Mou*_*ssi 8 visual-studio angular-seed angular

我刚从github克隆angular2-seed项目并按照步骤进行操作,但是我在VS代码中得到了这个警告[ts]对装饰器的实验支持是一个在将来的版本中可能会发生变化的功能.设置'Exxperimentaldecorators'选项以删除此警告.

小智 13

转到vscode中的文件/首选项/用户设置,输入此代码

{
  "typescript.tsdk": "node_modules/typescript/lib"
}
Run Code Online (Sandbox Code Playgroud)


Arv*_*iya 12

在 Visual Studio 代码中转到File -> Preferences -> Settings并检查Experimental Decorators

在此处输入图片说明


小智 9

在我创建的新服务上使用@Injectable()时遇到了这个问题.我从VS Code的打字稿编译器那里收到了警告.

当我将新服务作为提供程序添加到我打算使用它的模块时,警告消失了.

希望这能解决您的问题.


Jar*_*red 6

在您的tsconfig.json文件中,将您的项目路径添加到include属性中,如下所示:

"include": [
    "app/**/*"
]
Run Code Online (Sandbox Code Playgroud)

或者,您可以将单个文件添加到files属性中。这是我tsconfig.json的示例(对于 Angular2 应用程序):

{
    "compileOnSave": false,
    "buildOnSave": false,
    "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "moduleResolution": "node",
        "removeComments": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "noEmitHelpers": true,
        "sourceMap": true,
        "types": [
            "node"
        ],
        "typeRoots": [
            "../node_modules/@types"
        ],
        "lib": [
            "es2015",
            "dom"
        ]
    },
    "files": [
        "app/main.ts",
        "app/app.module.ts"
    ],
    "include": [
        "app/**/*.ts"
    ],
    "exclude": [
        "node_modules",
        "dist",
        "build",
        "app/main.aot.ts"
    ]
}
Run Code Online (Sandbox Code Playgroud)


小智 -1

这是由于使用旧版本的打字稿造成的。您必须升级您的打字稿版本才能删除此消息。

npm install -g typescript@latest
Run Code Online (Sandbox Code Playgroud)

您还需要将 npm 升级到最新版本。

  • 我已经有了最新版本的 typescript (2.0.3),我刚刚升级了 npm 但没有任何改变 (2认同)

归档时间:

查看次数:

10719 次

最近记录:

7 年,1 月 前