简体   繁体   English

ts棉绒上的experimentalDecorators警告

[英]experimentalDecorators Warning on ts lint

I'm getting typescript ts link warning, fired by the vs code. 我收到由vs代码触发的打字稿ts链接警告。 I get that when I mouse over the Service name which is HttpService which is underlined for some reason I cannot figure out. 当我将鼠标悬停在服务名称HttpService上时,由于某种原因,该名称带有下划线,我无法弄清楚。

[ts] Experimental support for decorators is a feature that is subject to change in a future release. [ts]对装饰器的实验支持是一项功能,在将来的版本中可能会更改。 Set the 'experimentalDecorators' option to remove this warning. 设置“ experimentalDecorators”选项以删除此警告。 class HttpService HttpService类

I mean I can do this on the tsconfig.json 我的意思是我可以在tsconfig.json上执行此tsconfig.json

{
    "compilerOptions": {
        "experimentalDecorators": true,
        "allowJs": true
    }
}

and that will remove the error, but, this is not a good practice as it sweeps the dirt under the carpet only for the time being. 这样可以消除错误,但是,这不是一个好习惯,因为它只能暂时清除地毯下的污垢。

What is it that we need to do so we do not have to deal with this? 我们需要做什么,这样我们就不必处​​理这个?

Is there something wrong almost in a barebone boilet plate code here? 此处的准骨Boilet板代码几乎有问题吗?

import {Injectable} from '@angular/core';
import {Http, Response, Headers, RequestOptions, ResponseContentType} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import 'rxjs/Rx';

@Injectable()
export class HttpService {

  constructor(private http: Http) {
  }

  getData(url: any) {
    const headers = new Headers();
    // headers.append('','');
    return this.http.get(url )
      .map((response: Response) => response.json());
  }


}

It is warning you that the line: 警告您,该行:

@Injectable()

Is technically an experimental feature. 技术上讲是一项实验功能。

You need to update your tsconfig.json with: 您需要使用以下命令更新tsconfig.json:

//...
"experimentalDecorators": true,
//...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 TS Lint警告消息 - TS Lint warning message 实验装饰器警告 - ExperimentalDecorators Warning 如何在 Eclipse 中为 angular4 项目消除experimentalDecorators警告 - How to get rid of experimentalDecorators warning in Eclipse for angular4 project 尝试手动注入 NgControl 时,Lint 警告“get is deprecated” - Lint warning “get is deprecated” when trying to manually inject NgControl 如何解决 NgRx 中的“避免连续调度许多操作”lint 警告? - How to resolve the "Avoid dispatching many actions in a row" lint warning in NgRx? 使用 controlValueAccessor 的自定义组件 - ts-Lint 错误:在定义之前使用了组件 - Custom component using controlValueAccessor - ts-Lint error: component was used before defined 角度构建的Visual Studio代码“ experimentalDecorators”问题 - Visual Studio Code 'experimentalDecorators' Issue for Angular Build Angular 4:如何在运行 npm 构建命令时禁用发出的 lint 警告? - Angular 4 : How to disable lint warning to emit when running npm build command? Angular 2:如何提供--module system --experimentalDecorators`标志? - Angular 2: how to provide `--module system --experimentalDecorators` flags? 如何摆脱 warning.ts 文件是 TypeScript 编译的一部分,但未使用 - How to get rid of the warning .ts file is part of the TypeScript compilation but it's unused
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM