You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 1, 2020. It is now read-only.
Repository navigation
This repository was archived by the owner on May 1, 2020. It is now read-only.
v1.3.8 - Lint task is throwing many "All imports are unused." #1052
I got this as well when going from v1.3.7 to v1.3.12. After finding your post I verified that indeed the issue would occur when going from v1.3.7 to v1.3.8. Plenty of false positives with "no-unused-variable": true
I haven't found a solution, but as a work-around, I went to an angular-cli project that I have and copied the rules from there, leaving out the codelyzer specific rules. The rules used for that project do not include no-unused-variables but do include a lot more formatting stuff. This had the added benefit of catching some places where I had gotten sloppy with spacing or placement of braces.
FWIW, turning no-unused-variable checking on in the angular-cli project had a similar effect with lots of false positives, so I am guessing that there is an issue with tslint and/or TypeScript language services, but that is only a guess on my part.
A lot of false positives. For example by simple importing OnInit and implement it in my class will trow an warning after the compilation saying the OnInt is not being used.
one trick to remove this warning in the import section of our .ts files, is disable temporary the rule 'no-unused-variable at the start of the file, and re-enable after all the imports are done:
I've seen this error fire when the imported class isn't being used appropriately. For example, if I import a class and use it as an interface, TSLint doesn't like it:
Fires the "All imports are unused":
import { MyClass } from './my-class';
export class AnotherClass {
public instance: MyClass;
constructor() {
this.instance = {
name: 'Dave'
};
}
}
Passes TSLint:
import { MyClass } from './my-class';
export class AnotherClass {
public instance: MyClass;
constructor() {
this.instance = new MyClass();
this.instance.name = 'Dave';
}
}
So, essentially, the imported class isn't recognized as being used, if it's used incorrectly.
Edit:
In Angular 2x, the EventEmitter requires a type; if the type used is a class, you need to instantiate the returned value (otherwise, TSLint will think MyClass is never used). For example:
public myEmitter = new EventEmitter<MyClass>();
// ...
this.myEmitter.emit(new MyClass({ ... }));
// Or...
this.myEmitter.emit({ ... } as MyClass);
Reacted by Tim Pankoke, aslaug sollilja and Anshuman Sahu
Also removed declare module '*' from declarations.d.ts and cleared a lot of this up for me. Worth noting declarations.d.ts is not generated in a new ionic project.
Yes the declaration.d.ts could be removed from ionic 3.3.0, per changelog:
Another optional step is to remove the src/declarations.d.ts file. This is a legacy file introduced early with ionic-angular projects to improve compatibility between TypeScript and third-party libraries. Due to improvements in TypeScript, this file is no longer necessary. By removing this file, the TypeScript compiler will be able to provide more accurate error messages for import statements.
I believe this issue can be closed.
Reacted by Roque, Johnni Mortensen, weirany, Nate Loftsgard, John F., Mario, Bilal YILMAZ and Alex Steinberg
I have to import some JavaScript modules files like this import Locomote from './assets/js/locomote.min';
removing declartion.d.ts file I run into this error:
Typescript Error
Module './assets/js/locomote.min' was resolved to '/abc/src/components/player/flash-player/assets/js/locomote.min.js', but '--allowJs' is not set.
Not sure which should be the right behavior of get TSLINT and custom js imports work together
Edit:
Adding allowJs to tsconfig.json does not resolve the problem and have other problems
Activity
kensodemann commentedon Jul 1, 2017
I got this as well when going from v1.3.7 to v1.3.12. After finding your post I verified that indeed the issue would occur when going from v1.3.7 to v1.3.8. Plenty of false positives with
"no-unused-variable": trueI haven't found a solution, but as a work-around, I went to an
angular-cliproject that I have and copied the rules from there, leaving out thecodelyzerspecific rules. The rules used for that project do not includeno-unused-variablesbut do include a lot more formatting stuff. This had the added benefit of catching some places where I had gotten sloppy with spacing or placement of braces.FWIW, turning
no-unused-variablechecking on in theangular-cliproject had a similar effect with lots of false positives, so I am guessing that there is an issue withtslintand/or TypeScript language services, but that is only a guess on my part.Here is what my tslint.json is for now:
akaztp commentedon Jul 4, 2017
Same here.
I've read that using typescript 2.4 solves it for tslint.
Unfortunately Typescript 2.4 is incompatible is RxJS5...
napcat commentedon Jul 18, 2017
I'm facing the same problem.
A lot of false positives. For example by simple importing OnInit and implement it in my class will trow an warning after the compilation saying the OnInt is not being used.
esase commentedon Jul 18, 2017
I have the same trouble. Ionic team why you didnt test carefully packages before release them?
JaneDawson commentedon Jul 18, 2017
Unfortunately, the same issue of many
unused importwarnings occurs with current app-scripts v. 2.0.2napcat commentedon Jul 19, 2017
Yes, I'm also on 2.0.2 and having this issue.
global packages:
ionic/cli-utils : 1.5.0
Cordova CLI : 6.5.0
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.2.2
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 : 5.3.0
AlejandroSilva commentedon Jul 21, 2017
one trick to remove this warning in the import section of our .ts files, is disable temporary the rule 'no-unused-variable at the start of the file, and re-enable after all the imports are done:
source: https://palantir.github.io/tslint/usage/rule-flags/
mburger81 commentedon Jul 22, 2017
@AlejandroSilva what do intend wirh re-enable after all imports are done.
The imports are all fine, tslints warning is justieren wrong.
piwibardy commentedon Jul 26, 2017
Same issue with version 2.1.0
daveywc commentedon Jul 31, 2017
I am getting the same issue on 2.0.2:
cli packages:
global packages:
local packages:
System:
Blackbaud-SteveBrush commentedon Jul 31, 2017
I've seen this error fire when the imported class isn't being used appropriately. For example, if I import a class and use it as an interface, TSLint doesn't like it:
Fires the "All imports are unused":
Passes TSLint:
So, essentially, the imported class isn't recognized as being used, if it's used incorrectly.
Edit:
In Angular 2x, the
EventEmitterrequires a type; if the type used is a class, you need to instantiate the returned value (otherwise, TSLint will thinkMyClassis never used). For example:jczaplew commentedon Aug 23, 2017
Per a comment here, removing
declare var *fromdeclarations.d.tsresolved this issue for me.daveywc commentedon Aug 24, 2017
@jczaplew Thanks for that.... for me it was removing
declare module '*'fromdeclarations.d.ts.josh-m-sharpe commentedon Aug 29, 2017
Also removed
declare module '*'fromdeclarations.d.tsand cleared a lot of this up for me. Worth notingdeclarations.d.tsis not generated in a new ionic project.mebibou commentedon Sep 6, 2017
Yes the
declaration.d.tscould be removed from ionic3.3.0, per changelog:I believe this issue can be closed.
rroque6428 commentedon Sep 6, 2017
Yeah, just remove 'src/declarations.d.ts' file. That did the trick. Thanks a LOT. One less problem in my life.
hardikns commentedon Oct 26, 2017
Yes removing src/declarations.d.ts worked. We can close this issue.
josh-m-sharpe commentedon Oct 26, 2017
Seems inappropriate to close this since others can still run into this and now have to find a closed GitHub issue to resolve it.
Removing the file should be baked into an upgrade script.
mburger81 commentedon Oct 31, 2017
I have to import some JavaScript modules files like this
import Locomote from './assets/js/locomote.min';removing
declartion.d.tsfile I run into this error:Not sure which should be the right behavior of get TSLINT and custom js imports work together
Edit:
Adding
allowJstotsconfig.jsondoes not resolve the problem and have other problemsAqib33 commentedon Jan 19, 2018
how to remove this declaration.d.ts file???????
mebibou commentedon Jan 19, 2018
@Aqib33 right click + delete ?
Aqib33 commentedon Jan 19, 2018
i mean where is this file please guide
Aqib33 commentedon Jan 19, 2018
@mebibou ??ill be able to delete only if i know where it is & how to do it
mebibou commentedon Jan 19, 2018
@Aqib33 I think it was in the
srcfolder before, but if you dont see it, then it's probably not there.Aqib33 commentedon Jan 19, 2018
its not there ;( please tell some, im stuck
mebibou commentedon Jan 19, 2018
@Aqib33 if you have a specific problem, then either go to stackoverflow or create a new issue, this is not a Q&A
Aqib33 commentedon Jan 19, 2018