Ionic 3.5.3 a lot warning about unused imports


#1

Hello, recently I have updated my ionic project, but now I see a lot of warnings like this:

[17:03:08] tslint: src/shared/components/avatar/index.ts, line: 1
’ChangeDetectorRef’ is declared but never used.

   L1:  import { Component, Input, ChangeDetectionStrategy, ChangeDetectorRef, OnInit, OnDestroy } from '@angular/co
   L2:  import { DataStore } from 'js-data';

But I use that import:

/**

  • Constructor
    */
    constructor(
    private events: Events,
    private api: DataStore,
    private ref: ChangeDetectorRef)
    {

The questions is why ionic thinks that it not used import?


Tslint:warning All imports are unused
#2

i have same question


#3

The warning is generated by the tslint run of the build process by @ionic/app-scripts, not Ionic Framework directly.

First: Does this affect your app or is it just a jslint warning?

Post your ionic info output please.


#4

Maybe I have wrong ts configs?

tsconfig:

{
“compilerOptions”: {
“allowSyntheticDefaultImports”: true,
“declaration”: false,
“emitDecoratorMetadata”: true,
“experimentalDecorators”: true,
“lib”: [
“dom”,
“es2017”
],
“module”: “es2015”,
“moduleResolution”: “node”,
“sourceMap”: true,
“target”: “es5”,
“baseUrl”: “src”,
“paths”: {
“assets/": [ "assets/” ],
“pages/": [ "pages/” ],
“services/": [ "services/” ],
“shared/": [ "shared/” ]
}
},
“include”: [
“src/**/*.ts”
],
“exclude”: [
“node_modules”
],
“compileOnSave”: false,
“atom”: {
“rewriteTsconfig”: false
}
}

tslint.json:

{
“rules”: {
“no-duplicate-variable”: true,
“no-unused-variable”: [
true,
{
“ignore-pattern”: “Page$”
}
]
},
“rulesDirectory”: [
“node_modules/tslint-eslint-rules/dist/rules”
]
}


#5

Compare it to the default ones: https://github.com/ionic-team/ionic2-app-base

Also post your ionic info output and package.json please.


#6

I am having the same issue. It seems like this was caused by the recent appscripts release. Apparently they are working to fix that, though.


#7

Is there an issue already to link to?


#8

Not that I know of. I found one but seems to be just one of the issues: