Igniteui-angular: Excel Exporter - build error occurs when noImplicitAny is set to true

Created on 5 Mar 2019  Â·  17Comments  Â·  Source: IgniteUI/igniteui-angular

Description

When noImplicitAny is set to true, build process fails. If noImplicitAny is not set explicitly, build process succeeds.

  • igniteui-angular version: 7.1.9
  • browser: n/a

Steps to reproduce

  1. Build the attached sample by ng build --prod
  2. Observe the console

Result

Build fails with the following message:
_ERROR in node_modules/igniteui-angular/lib/services/excel/excel-exporter.d.ts(1,24): error TS7016: Could not find a declaration file for module 'jszip/dist/jszip'. 'C:/Users/ymita/OneDrive - Infragistics, Inc/Cases/30963/app1/node_modules/jszip/dist/jszip.js' implicitly has an 'any' type.
Try npm install @types/jszip if it exists or add a new declaration (.d.ts) file containing declare module 'jszip/dist/jszip';_

Expected result

Build succeeds.

Attachments

app1.zip

bug excel-exporter medium resolved

Most helpful comment

Hi @mtsvyatkova,

Type definition @types/jszip is available. Can we solve the error by using this?

In our product, import path is from jszip/dist/jszip. A thread on StackOverflow, import path is just from jszip. Does the second way make any difference? https://stackoverflow.com/questions/43097159/import-jszip-in-angular-2-project#43137697

All 17 comments

The issue is related to the third-party JSZip class as in the jszip.js file no type information is provided. Setting the "noImplicitAny" property in the tsconfig.json file to true will cause an error to be displayed because of those missing types.
I would suggest using the Excel-Exporter with the "noImplicitAny" set to false to workaround this behavior.

Hi @mtsvyatkova,

Type definition @types/jszip is available. Can we solve the error by using this?

In our product, import path is from jszip/dist/jszip. A thread on StackOverflow, import path is just from jszip. Does the second way make any difference? https://stackoverflow.com/questions/43097159/import-jszip-in-angular-2-project#43137697

@mtsvyatkova, is there an update on this?

@ymita
Adding the type definition @types/jszip required some changes in our implementation for the Excel Exporter. The code is building now but not all tests are passing so I am working on this.

There is an issue with the jszip module which results in an error thrown in the readable-stream-browser.js file when using the @typings/jszip in our source.

StreamError

This is logged in the Stuk/jszip repository. The suggested workaround is to set the path for the jszip module on application level in the tsconfig.ts file

{
  ...
  "compilerOptions": {
    ...
    "paths": {
      "jszip": [
        "../node_modules/jszip/dist/jszip.min.js"
      ]
    }
  }
}

The above will reflect the applications using our source so I am not sure that we should add the typings for the jszip module at this point.

@mtsvyatkova
Thank you for your suggestion. I set the path like in the attached app.zip application. But it still throws the same error. If you have a working sample that work around the issue, can you share it with me?

    "paths": {
      "jszip": [
        "./node_modules/jszip/dist/jszip.min.js"
      ]
    }

@ymita
The suggested approach for setting the path to the jszip would only work if the @typings/jszip are included in our source. If you would like to test this, you need to pull the changes from one of the PRs referencing the issue and build the app1 application (with the path set as above) against these changes.

Is the issue with the noImplicitAny property reported by a customer?

@mtsvyatkova Thanks for your clarification. For your question, yes, this is reported by a customer.

@ymita
At this point we won't be adding the @types/jszip to our library because of the third-party issue with the paths mentioned above.

As a workaround, the definition files for the jszip library could be added to the end user's project so that the noImplicitAny property could be set to true for that project. The steps that I followed to achieve that are:

  1. Run 'npm install' for the app1 project.
  2. Run 'npm i @types/jszip'.
  3. Change the import path for the jszip from 'jszip/dist/jszip' to just 'jszip' in the excel-exporter.d.ts file.

@mtsvyatkova
Thank you for the workaround above. This requires modification on our source code so that this cannot be delivered to our customers.

@zdrawku
From customer support perspective, can we add this set of configuration and feature as a known limitation on our documentation? This will help our customers to know it as a point to notice.

@ymita @mtsvyatkova So, to be clear, the workaround is to edit files in the node_modules file for IgniteUI or turn off noImplicitAny in our tsconfig.json?

@jahumes Yes, your understanding is correct.

@ymita is there another way? This is the blocking issue for me.

Thank you

@pnguyen535 As far as I am aware of, there is no other way.

It’s ok. I found a way to make it work with my CI/CD

Sent from Yahoo Mail for iPhone

On Thursday, June 13, 2019, 5:10 PM, Yuki Mita notifications@github.com wrote:

@pnguyen535 As far as I am aware of, there is no other way.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

PR still not merged

JSZip issue is now fixed and we can include the @types/jszip.

Was this page helpful?
0 / 5 - 0 ratings