[英]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.