ionic-team / ionic-app-scripts

App Build Scripts for Ionic Projects
http://ionicframework.com/
MIT License
608 stars 302 forks source link

[1.3.12] Wrong lint warning when import is only use as declaration #1074

Open peterpeterparker opened 7 years ago

peterpeterparker commented 7 years ago

Short description of the problem:

With app-scripts 1.3.12, when an import is only use as declaration, tslint will display this import as never used

What behavior are you expecting?

No warning

Steps to reproduce:

  1. See code example
  2. Run ionic serve
  3. Access the page in the browser so tslint will be called

Code

import {Slides} from 'ionic-angular';

@Component({
    templateUrl: 'test.html',
    selector: 'test'
 })
 export class TestPage  {
    @ViewChildren('mySlider') private slides: QueryList<Slides>;
}

tslint output

[11:34:13] tslint: src/pages/test.ts, line: 5 'Slides' is declared but never used.

L5: import {Slides} from 'ionic-angular';

Which @ionic/app-scripts version are you using?

1.3.12

Other information: (e.g. stacktraces, related issues, suggestions how to fix, stackoverflow links, forum links, etc)

global packages:

@ionic/cli-utils : 1.4.0
Cordova CLI      : 7.0.1 
Gulp CLI         : CLI version 1.2.2 Local version 3.9.1
Ionic CLI        : 3.4.0

local packages:

@ionic/app-scripts              : 1.3.12
@ionic/cli-plugin-cordova       : 1.4.0
@ionic/cli-plugin-gulp          : 1.0.1
@ionic/cli-plugin-ionic-angular : 1.3.1
Cordova Platforms               : android 6.2.3 ios 4.4.0
Ionic Framework                 : ionic-angular 3.5.0

System:

Node       : v8.1.3
OS         : macOS Sierra
Xcode      : Xcode 8.3.3 Build version 8E3004b 
ios-deploy : 1.9.0 
ios-sim    : 5.0.13 
npm        : 5.0.4 
sfabriece commented 7 years ago

slightly related i'm getting linting error where I've disabled linting with comment

// tslint:disable has no effect

mburger81 commented 7 years ago

Same issue here

chilloutman commented 7 years ago

Duplicate of #1052, where the same issue was already occurring on 1.3.8.

rodneyjoyce commented 7 years ago

Another example:

import { Pipe, PipeTransform } from '@angular/core';
@Pipe({  name: 'bookingStatusForRating' })
export class BookingStatusForRatingPipe implements PipeTransform {

results in " 'PipeTransform' is declared but never used." when it clearly is.

LufoX11 commented 7 years ago

I'm facing this issue as well. In my case, I've upgraded from ionic@2.2.3 to (current) latest ionic@3.6.0. If someone, in Ionic stuff, need a live example, I can provide you with the entire project. Thanks.

rroque6428 commented 7 years ago

Also a problem for me. I just updated the Ionic scripts today and got lots of ' ... is declared but never used.' for imports that are actually being used. Really annoying. But the build works normally.

My env:

    @ionic/cli-plugin-ionic-angular : 1.4.1
    @ionic/cli-utils                : 1.7.0
    ionic (Ionic CLI)               : 3.7.0

global packages:

    Cordova CLI : 6.5.0

local packages:

    @ionic/app-scripts        : 2.1.3
    @ionic/cli-plugin-cordova : 1.4.1
    Cordova Platforms         : android 6.1.2
    Ionic Framework           : ionic-angular 3.6.0

System:

    Android SDK Tools : 25.2.5
    Node              : v6.9.1
    OS                : Windows 8.1
    npm               : 4.1.1
lostdev commented 7 years ago

I've got the same issue as @rroque6428 above, but I'm on 3.7.0.

Ionic info:

cli packages: (C:\git\mobile\node_modules)

    @ionic/cli-plugin-cordova       : 1.6.2
    @ionic/cli-plugin-ionic-angular : 1.4.1
    @ionic/cli-utils                : 1.7.0
    ionic (Ionic CLI)               : 3.7.0

global packages:

    Cordova CLI : 7.0.1

local packages:

    @ionic/app-scripts : 2.1.3
    Cordova Platforms  : android 6.2.3 ios 4.3.1
    Ionic Framework    : ionic-angular 3.6.0

System:

    Android SDK Tools : 25.2.5
    Node              : v6.10.3
    OS                : Windows 8.1
    npm               : 3.10.8
bollatialfredo commented 7 years ago

Same issue as @lostdev @rroque6428 @peterpeterparker.

cli packages: (//node_modules)

    @ionic/cli-plugin-cordova       : 1.6.1
    @ionic/cli-plugin-ionic-angular : 1.4.1
    @ionic/cli-utils                : 1.7.0
    ionic (Ionic CLI)               : 3.7.0

global packages:

    Cordova CLI : 7.0.1 

local packages:

    @ionic/app-scripts : 1.3.12
    Cordova Platforms  : android 6.2.3 ios 4.4.0
    Ionic Framework    : ionic-angular 3.0.1

System:

    Node : v6.11.2
    OS   : Linux 4.10
    npm  : 3.10.10 
pishonx commented 7 years ago

strange, I also just updated my dependencies, now my app does not work anymore :/ Same issue here:

cli packages: (/Users/pichonx/Development/tendbe/tb-mobile/node_modules)

@ionic/cli-utils  : 1.9.2
ionic (Ionic CLI) : 3.9.2

local packages:

@ionic/app-scripts : 2.1.0
Ionic Framework    : ionic-angular 3.5.3

System:

Node : v6.9.1
npm  : 3.10.8 
OS   : macOS Sierra

does sombody have found something yet?

rroque6428 commented 7 years ago

Solved. Check #1052

In short: just remove 'src/declarations.d.ts' file (refer to the above thread for details)

peterpeterparker commented 7 years ago

Thx @rroque6428 but the issue you listed doesn't solve this issue.

My project already doesn't contains any declarations.d.ts

The issue is therefore still open.

arfaWong commented 6 years ago

Thx @rroque6428 the issue you listed did solve this issue.

mburger81 commented 6 years ago

not sure if removing the file is the right solution, we need the declaration file because we import third part javascript files.

alawneh0 commented 6 years ago

is the problem solved for anyone ?

shahriar commented 6 years ago

Here is the solution https://github.com/ionic-team/ionic-app-scripts/issues/1052#issuecomment-324613840

jgerstle commented 6 years ago

Removing declarations.d.ts didn't help me either. It seems like this issue is supposed to be fixed in newer typescript versions, but I am still having issues even with ts 1.5.3: https://github.com/palantir/tslint/issues/2470

ArezooK commented 6 years ago

I also have this issue and deleting the declaration.d.ts file removed some of the false positive warnings I have but not all of them.