简体   繁体   中英

experimentalDecorators Warning on ts lint

I'm getting typescript ts link warning, fired by the vs code. I get that when I mouse over the Service name which is HttpService which is underlined for some reason I cannot figure out.

[ts] Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning. class HttpService

I mean I can do this on the 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?

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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM