Search code examples
filecordovaionic5

File import not initializing in constructor ionic native. The cordova file plugin and javascript file interface is conflicting .?


import { File } from '@ionic-native/file/ngx';

I can’t use the class File from cordova-plugin-file in my application cause there is another interface from JavaScript also called File.

This name conflict impedes my app to access the cordova-plugin-file functions I want.

File from JavaScript has this description : “ interface File Provides information about files and allows JavaScript in a web page to access their content.”.

File from cordova-plugin-file should (alias) const File: FileOriginal import File 'File' is declared but its value is never read

Here is my code :

import { File } from '@ionic-native/file/ngx';
export class Tab1Page {
constructor(public file: File) {}
...
}

Solution

  • Just so that it helps someone. Workaround was to declare cordova-plugin-file outside constructor.

    import { File as cordova_file } from '@ionic-native/file/ngx';
    private file: typeof cordova_file
    constructor(