cipchk/ngx-filesaver

Compilation error: Property '"method"' is incompatible with index signature.

xuyinofnyc opened this issue · 4 comments

I am using Angular core 15.2.0, and tried 14.0.0, 15.0.0 and 16.0.0 versions of ngx-filesaver and all got following error:

Error: node_modules/ngx-filesaver/src/filesaver.directive.d.ts:30:94 - error TS2344: Type '{ method: { alias: "method"; required: false; }; http: { alias: "http"; required: false; }; query: { alias: "query"; required: false; }; header: { alias: "header"; required: false; }; url: { alias: "url"; required: true; }; fileName: { ...; }; fsOptions: { ...; }; }' does not satisfy the constraint '{ [key: string]: string; }'.

Property '"method"' is incompatible with index signature.

Type '{ alias: "method"; required: false; }' is not assignable to type 'string'.

30 static ɵdir: i0.ɵɵDirectiveDeclaration<FileSaverDirective, "[fileSaver]", ["fileSaver"], { "method": { "alias": "method"; "required": false; }; "http": { "alias": "http"; "required": false; }; "query": { "alias": "query"; "required": false; }; "header": { "alias": "header"; "required": false; }; "url": { "alias": "url"; "required": true; }; "fileName": { "alias": "fileName"; "required": false; }; "fsOptions": { "alias": "fsOptions"; "required": false; }; }, { "success": "success"; "error": "error"; }, never, never, true, never>;

Seems the grammar is not compatible with Angular. What am I missing?

cipchk commented
  1. Make sure to use angular, ngx-filesaver is 15.x
  2. Try to remove node_modules and package.json (or yarn.lock),
  3. Finally yarn installs dependencies

I tried

npm install ngx-filesaver@15.x
Same error.
For Angular, I am using Angular cli 15.2.0.
What do you mean remove node_modules?

Using yarn seems working, but not npm. I have to rely on npm now. Can this be fixed?

cipchk commented

This problem should be the result of not installing dependencies correctly. It should not be directly related to ngx-filesaver. You can use npm ls -a to check whether the specific dependency version details are correct.