Name conflict between cordova-plugin-file and Javascript File interface

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

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

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

File from cordova-plugin-file should allow to read/write access to files residing on the device.

Here is my code :

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

Thanks for your help :slight_smile:

What version of ionic-native/file is in your package.json?

I just tested things out and it still works fine.

If you’re worried about the types though, you can use the import/as approach

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

This way you will have NativeFile as the symbol, and it wont conflict with the built in

I got this on package.json

"@ionic-native/file": "^5.22.0"

Ok, so if you have 5.22, you’ll want to import things from '@ionic-native/file/ngx';

1 Like