I just installed the ngx-filesaver using:
npm install file-saver ngx-filesaver
Then in app.module.ts added:
import { FileSaverModule } from 'ngx-filesaver';
...
@NgModule({
imports: [
...
FileSaverModule
],
...
})
Then I have this compilation 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>;
What am I missing here, and what is the remedy?
ngx-filesaver
's versions track Angular's version, so if for example you're on Angular 14 you would install the package withnpm install [email protected]
instead ofnpm install ngx-filesaver
(which will install the latest version, i.e.16.0.0
) – Toiletry