igniteui-angular icon indicating copy to clipboard operation
igniteui-angular copied to clipboard

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

Open ymita opened this issue 7 years ago • 17 comments

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

ymita avatar Mar 05 '19 05:03 ymita

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.

mtsvyatkova avatar Mar 05 '19 14:03 mtsvyatkova

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

ymita avatar Mar 07 '19 07:03 ymita

@mtsvyatkova, is there an update on this?

ymita avatar Mar 26 '19 05:03 ymita

@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.

mtsvyatkova avatar Mar 27 '19 08:03 mtsvyatkova

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 avatar Apr 05 '19 07:04 mtsvyatkova

@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 avatar Apr 10 '19 06:04 ymita

@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 avatar Apr 11 '19 08:04 mtsvyatkova

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

ymita avatar Apr 15 '19 05:04 ymita

@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 avatar Apr 17 '19 10:04 mtsvyatkova

@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 avatar May 08 '19 01:05 ymita

@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?

observstream avatar May 16 '19 13:05 observstream

@jahumes Yes, your understanding is correct.

ymita avatar May 17 '19 05:05 ymita

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

Thank you

pnguyen535 avatar Jun 04 '19 14:06 pnguyen535

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

ymita avatar Jun 14 '19 00:06 ymita

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 [email protected] 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.

pnguyen535 avatar Jun 15 '19 03:06 pnguyen535

PR still not merged

radomirchev avatar Aug 30 '19 13:08 radomirchev

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

DiyanDimitrov avatar Apr 01 '20 21:04 DiyanDimitrov