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

时间:2016-11-21 20:29:01

标签: angular meteor typescript phpstorm webstorm

您已更新到最新的WebStorm,我现在收到此错误:

Error:(52, 14) TS1219:Experimental support for decorators 
is a feature that is subject to change in a future release. 
Set the 'experimentalDecorators' option to remove this warning.

但在我的tsConfig experimentalDecorators设置为true:

{
  "version": "1.5.0",
  "compilerOptions": {
    //...,
    "experimentalDecorators": true,   // <======== HERE
    //...,
  },
  "files": [
    //...
  ],
  "exclude": [ "node_modules" ]
}

3 个答案:

答案 0 :(得分:19)

仅当文件包含在文件中时,

WS2016.3 才会将配置设置应用于文件。或者包括&#39; tsconfig.json部分。 [More info about tsconfig.json]

因此配置必须包含所有项目文件(或者如果你有几个部分的应用程序,你可以有几个tsconfig.json文件)。否则,typescript服务使用该文件的默认打字稿选项。

首选解决方案

您的 tsconfig.json 应为:

{
  "version": "1.5.0",
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "noImplicitAny": false,
    "removeComments": true,
    "noLib": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true, 
    "sourceMap": true,
    "listFiles": true,
    "isolatedModules": false,
    "moduleResolution": "node",
    "suppressImplicitAnyIndexErrors": true
  },
  "include": [
    "typings/thera/thera.d.ts",
    "typings/browser.d.ts",
    "typings/main.d.ts",
    "typings/meteor.d.ts",
    "typings/meteor_server.d.ts",
    "your_app_directory/**/*" 
  ],
  "exclude": [ "node_modules" ],
  "compileOnSave":false //not required but is suggested for meteor projects
}

另一种解决方案

您可以在TypeScript设置中指定默认选项(如果您不想自动编译,则应取消选中track changes选项):

TypeScript Settings

注意:如果您不喜欢新行为,可以在&#34;文件|中禁用打字稿服务集成。设置|语言与框架|打字稿&#34; - &GT; &#34;使用TypeScript服务&#34;。

答案 1 :(得分:9)

同样适用于WebStorm 2020.1.2。谢谢。

enter image description here

答案 2 :(得分:2)

  1. 打开文件->设置->语言和框架->打字稿
  2. 在“选项”输入中添加@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String name= request.getParameter("name"); String description = request.getParameter("description"); String prix = request.getParameter("prix"); String image; String chemin = getInitParameter( CHEMIN); Part part = request.getPart("file"); String fileName =Paths.get(part.getSubmittedFileName()).getFileName().toString(); String fullPath = chemin + fileName; if ( fileName != null && !fileName.isEmpty() ) { fileName = fileName.substring( fileName.lastIndexOf( '/' ) + 1 ) .substring( fileName.lastIndexOf( '\\' ) + 1 ); fwrite( part, fileName, fullPath ); File srcFile = new File( fullPath ); byte [] buffer = new byte[ (int) srcFile.length() ]; try ( FileInputStream inputStream = new FileInputStream( srcFile ) ) { inputStream.read( buffer ); } } image = fullPath; manager.addBurger(name, description, prix, image); RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(VUE); dispatcher.forward(request, response); }

enter image description here

点击右下角的应用按钮