I’ve just updated to Ionic 3.5.3, and I’m noticing a pattern of frequent “All imports are unused” lint warnings --when, in fact the imports are used.
Example warning:
[17:00:26] tslint: ...example.ts, line: 2
All imports are unused.
L1: import { Injectable } from '@angular/core';
L2: import { Http } from '@angular/http';
L3: import 'rxjs/add/operator/map';
referring to the following code:
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/map';
import { ConstProvider } from '../providers/example';
@Injectable()
export class Example{
public data: any;
constructor( public http: Http, private constProvider: ConstProvider ) {}
today() {
if (this.data) {
return Promise.resolve(this.data);
}
return new Promise(resolve => {
this.http.get(this.constProvider.apiURL + '/example')
.map(res => res.json())
.subscribe(data => {
this.data = data;
resolve(this.data);
});
});
}
}
This code works fine. Just get lint warnings on ionic serve, ionic cordova build, ionic upload
global packages:
@ionic/cli-utils : 1.5.0
Cordova CLI : 7.0.1
Ionic CLI : 3.5.0
local packages:
@ionic/app-scripts : 2.0.2
@ionic/cli-plugin-cordova : 1.4.1
@ionic/cli-plugin-ionic-angular : 1.3.2
Cordova Platforms : android 6.1.2 browser 4.1.0 ios 4.3.1
Ionic Framework : ionic-angular 3.5.3
System:
Node : v6.11.1
OS : Windows 10
Xcode : not installed
ios-deploy : not installed
ios-sim : not installed
npm : 3.10.10