Build error with ionic-app-script and cordova plugin

Hi,

I’ve this error when i launch ionic serve :
ionic-app-scripts watch

[22:09:31]  ionic-app-scripts 0.0.36 
[22:09:31]  watch started ... 
[22:09:31]  build dev started ... 
[22:09:31]  clean started ... 
[22:09:31]  clean finished in 3 ms 
[22:09:31]  copy started ... 
[22:09:31]  transpile started ... 
[22:09:35]  typescript: /src/pages/file-browser/file-browser.ts, line:             Cannot find name 'FileEntry'.  
....
Property 'resolveLocalFileSystemURL' does not exist on type 'Window'. 
L23:  window.**resolveLocalFileSystemURL**(path, function (fileSystem) {
L24:      fileSystem.getParent(function (result) {
[22:09:35]  transpile failed 


--------------------------------
--------------------------------

Your system information:

Cordova CLI: 6.3.1
Ionic Framework Version: 2.0.0-rc.1
Ionic CLI Version: 2.1.1
Ionic App Lib Version: 2.1.1
Ionic App Scripts Version: 0.0.36
OS:
Node Version: v6.7.0
--------------------------------

Package.json 

"dependencies": {
    "@angular/common": "^2.0.0",
    "@angular/compiler": "^2.0.0",
    "@angular/compiler-cli": "0.6.2",
    "@angular/core": "^2.0.0",
    "@angular/forms": "^2.0.0",
    "@angular/http": "^2.0.0",
    "@angular/platform-browser": "^2.0.0",
    "@angular/platform-browser-dynamic": "^2.0.0",
    "@angular/platform-server": "^2.0.0",
    "@ionic/storage": "^1.0.3",
    "@types/cordova": "0.0.34",
    "@types/cordova-ionic": "0.0.29",
    "@types/cordova-plugin-background-mode": "0.0.15",
    "@types/cordova-plugin-file": "0.0.3",
    "@types/cordova-plugin-file-transfer": "0.0.3",
    "@types/mime": "0.0.29",
    "angular2-moment": "^1.0.0-beta.5",
    "chart.js": "^2.3.0",
    "ionic-angular": "^2.0.0-rc.1",
    "ionic-native": "^2.2.3",
    "ionicons": "^3.0.0",
    "mime": "^1.3.4",
    "mime-types": "^2.1.12",
    "moment": "^2.15.1",
    "ng2-charts": "^1.4.0",
    "ng2-translate": "^3.1.2",
    "rxjs": "5.0.0-beta.12",
    "zone.js": "^0.6.21"
  },
  "devDependencies": {
    "@ionic/app-scripts": "^0.0.36",
    "typescript": "^2.0.3"
  },
  "cordovaPlugins": [
    "cordova-plugin-device",
    "cordova-plugin-console",
    "cordova-plugin-whitelist",
    "cordova-plugin-splashscreen",
    "cordova-plugin-statusbar",
    "ionic-plugin-keyboard",
    "cordova-plugin-file",
    "cordova-plugin-file-transfer",
    "cordova-plugin-background-mode"
  ],

i’ve tested : rm -rf /node_modules | ionic state reset | npm install

I see under node_modules/@types/cordova-plugin-file/index.d.ts the description of fileEntry…so i don’t understand !

Same error…any idea ?

Thx !

You can use the wrapper provided by Ionic Native for the file plugin, instead of using @types/cordova-plugin-file

See http://ionicframework.com/docs/v2/native/file/ for documentation.

Here’s a quick example:


import { File } from 'ionic-native';

File.resolveLocalFileSystemUrl('/path/to/file/or/directory')
  .then(() => console.log('File exists'))
  .catch((e) => console.log('File doesnt exist', e));

Yeah ! It’s OK for FileEntry and resolveLocalFileSystemUrl but I still have the following error :

cordova.file.* cordova not found

In fact, cordova-plugin-file exposes some cordova.* string to define file store (cordova-plugin-file) .

The ionic-native File plugin doesn’t expose the cordova.* string. So it’s why I use @types/cordova-plugin-file because it describes cordova.file.*.

May be, i need to put a issue/PR to expose this interface into the File ionic native plugin ?

Well you still don’t need the @types
you can do something like this:


declare var cordova: any;

File.doSomething(cordova.file.cacheDirectory);

An issue/PR to add it to the Ionic Native wrapper would be helpful too :slight_smile:

Just need to add something like this to the File class:

@CordovaProperty
get cacheDirectory(): string { 
  return cordova.file.cacheDirectory;
}