Localforage : Subsequent variable declarations must have the same type

Hello,

I got a problem to serve Ionic 2

I clone the repo of my client then :

$ npm i

$ ionic serve

and I got this error :

Running 'serve:before' npm script before serve
> myapp@ watch /Users/dev/DEV/MOBILE/myapp
> ionic-app-scripts watch --copy copy.config.js
[21:23:32]  ionic-app-scripts 1.1.4
[21:23:32]  watch started ...
[21:23:32]  build dev started ...
[21:23:32]  clean started ...
[21:23:32]  clean finished in 1 ms
[21:23:32]  copy started ...
[21:23:32]  transpile started ...
[21:23:37]  typescript: node_modules/@types/localforage/index.d.ts, line: 7
Subsequent variable declarations must have the same type. Variable 'driver' must be of type 'string |
[21:23:37]  typescript: node_modules/@types/localforage/index.d.ts, line: 15
[21:23:37]  typescript: node_modules/@types/localforage/index.d.ts, line: 25
[21:23:37]  typescript: node_modules/@types/localforage/index.d.ts, line: 25
[21:23:37]  typescript: node_modules/@types/localforage/index.d.ts, line: 100
[21:23:37]  typescript: node_modules/localforage/typings/localforage.d.ts, line: 47
[21:23:37]  typescript: node_modules/localforage/typings/localforage.d.ts, line: 52
[21:23:37]  typescript: node_modules/localforage/typings/localforage.d.ts, line: 113
[21:23:37]  transpile failed
string[]', but here has type 'string | LocalForageDriver | LocalForageDriver[]'.

L6:      size?: number;
L8:      storeName?: string;

Subsequent variable declarations must have the same type. Variable 'version' must be of type 'number', but
here has type 'string'.

L15:  interface LocalForageDriver {
L16:      _driver: string;

Subsequent variable declarations must have the same type. Variable '_support' must be of type 'boolean |
LocalForageDriverSupportFunc', but here has type 'boolean | Promise<boolean>'.

L24:      getItem(key: string, callback: (err: any, value: any) => void): void;
L26:      key(keyIndex: number, callback: (err: any, key: string) => void): void;

All declarations of '_support' must have identical modifiers.

L24:      getItem(key: string, callback: (err: any, value: any) => void): void;
L26:      key(keyIndex: number, callback: (err: any, key: string) => void): void;

Duplicate identifier 'export='.


Interface 'LocalForageDriver' incorrectly extends interface 'LocalForageDbMethods'. Types of property
'getItem' are incompatible. Type '(key: string, callback: (err: any, value: any) => void) => void' is not
assignable to type '{ <T>(key: string): Promise<T>; <T>(key: string, callback: (err: any, value: T) =>
void): void; }'.

L46:  interface LocalForageDriver extends LocalForageDbMethods {
L47:      _driver: string;

All declarations of '_support' must have identical modifiers.

L51:      _support?: boolean | LocalForageDriverSupportFunc;

Duplicate identifier 'export='.

L112:      export = localforage;

[21:23:37]  watch ready in 4.71 s
Running live reload server: http://localhost:35729
Watching: www/**/*, !www/lib/**/*, !www/**/*.map
√ Running dev server:  http://localhost:8100
Ionic server commands, enter:
restart or r to restart the client app from the root
goto or g and a url to have the app navigate to the given url
consolelogs or c to enable/disable console log output
serverlogs or s to enable/disable server log output
quit or q to shutdown the server and exit

ionic $ [21:23:37]  copy finished in 4.75 s

My ionic info :

Your system information:

Cordova CLI: 6.5.0
Ionic Framework Version: 2.0.0-rc.4
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 1.1.4
ios-deploy version: 1.9.0
ios-sim version: 5.0.8
OS: macOS Sierra
Node Version: v6.9.2
Xcode version: Xcode 8.2.1 Build version 8C1002

The package.json :

{
"dependencies": {
"@angular/common": "2.2.1",
"@angular/compiler": "2.2.1",
"@angular/compiler-cli": "2.2.1",
"@angular/core": "2.2.1",
"@angular/forms": "2.2.1",
"@angular/http": "2.2.1",
"@angular/platform-browser": "2.2.1",
"@angular/platform-browser-dynamic": "2.2.1",
"@angular/platform-server": "2.2.1",
"@angular/router": "3.2.1",
"@ionic/cloud-angular": "^0.8.0",
"@ionic/storage": "1.1.7",
"font-awesome": "^4.7.0",
"he": "^1.1.1",
"ionic-angular": "2.0.0-rc.4",
"ionic-gulp-browserify-typescript": "^2.0.0",
"ionic-native": "^2.2.11",
"ionicons": "^3.0.0",
"localforage": "^1.4.2",
"moment": "^2.15.1",
"moment-timezone": "^0.5.6",
"reflect-metadata": "^0.1.8",
"rxjs": "5.0.0-beta.12",
"zone.js": "0.6.26",
"@ionic/app-scripts": "=1.0.0"
},
"devDependencies": {
"typescript": "2.0.9"
},
"name": "myapp",
"description": "MyApp: An Ionic project",
"author": "Myapp",
"scripts": {
"build": "ionic-app-scripts build --prod --copy copy.config.js",
"watch": "ionic-app-scripts watch --copy copy.config.js",
"serve:before": "watch",
"emulate:before": "build",
"deploy:before": "build",
"build:before": "build",
"run:before": "build"
},
"cordovaPlugins": [
"cordova-plugin-badge@~0.7.3",
"cordova-plugin-screen-orientation@~1.4.2",
"ionic-plugin-deeplinks@~1.0.12",
"cordova-plugin-compat@~1.1.0",
"onesignal-cordova-plugin@~2.0.8",
"cordova-plugin-calendar@~4.5.5",
"cordova-plugin-x-socialsharing@~5.1.3",
"cordova-plugin-wkwebview-engine@~1.1.0",
"ionic-plugin-keyboard@~2.2.1",
"ionic-plugin-deploy@~0.6.5",
"cordova-plugin-whitelist@~1.3.0",
"cordova-plugin-statusbar@~2.2.0",
"cordova-plugin-crosswalk-webview@~2.2.0",
"cordova-plugin-device@~1.1.3",
"cordova-plugin-network-information@~1.3.0",
"cordova-plugin-splashscreen@~4.0.0",
"cordova-plugin-geolocation@~2.4.0",
"cordova-plugin-inappbrowser@~1.5.0",
"cordova-plugin-camera@~2.3.0",
"cordova-plugin-app-version@~0.1.9",
"cordova-plugin-google-analytics@~1.7.1",
"onesignal-cordova-plugin",
"cordova-plugin-badge",
"cordova-plugin-screen-orientation",
"cordova-plugin-app-event",
"ionic-plugin-deeplinks",
"cordova-plugin-compat",
"cordova-plugin-calendar",
"cordova-plugin-x-socialsharing",
"cordova-plugin-wkwebview-engine",
"ionic-plugin-keyboard",
"ionic-plugin-deploy",
"cordova-plugin-whitelist",
"cordova-plugin-statusbar",
"cordova-plugin-crosswalk-webview",
"cordova-plugin-device",
"cordova-plugin-network-information",
"cordova-plugin-splashscreen",
"cordova-plugin-geolocation",
"cordova-plugin-inappbrowser",
"cordova-plugin-app-version",
"cordova-plugin-google-analytics@1.0.0"
]
}

Someone can help me please ? :slight_smile: Thank you !

1 Like

I got this today… downgrade localforage from 1.5.0 to 1.4.x
i maded it a permanent dependency in my package.json
its seems used by ionic.storage now i prefer to use the simple plain library because all those wrapper have problems

localforage is already on ^1.4.2

put localstorage to =1.4.0 in the package.json solve the problem, thx ! :smiley:

It looks to me like localforage now has typings included in the package, so what I would do instead of downgrading it would be to remove @types/localforage.

1 Like

… let me try … hold one …

I’m curious what these problems are. The only trouble I’ve ever had with it was caused by my failure to read the changelog and learn about the ready function added relatively recently.

about localforage? ok i had issue with the old ngCordova
about ionic native? well not related to localforage but the API is a non-sense, impossible to get the watcherID to cancel the gps’s watcher

i prefer to use the libraries/plugins directly - that makes the chain shorter

ok removing @types/localforage does work for me
but issuing npm install will recreate it again

We’re drifting off topic, but looks pretty straightforward to me: just unsubscribe from the Observable returned by watchPosition and the watcher will be cancelled for you.

Either use the --save-dev option when uninstalling it or vape it out of package.json manually.

thanks for pointing out the unsubscribe thing but maybe i used a wrong example :slight_smile:

back on topic i don’t have it as direct dependency but thanks anyway its late for me and i’m fine with 1.4.x

"dependencies": { "@angular/common": "2.2.1", "@angular/compiler": "2.2.1", "@angular/compiler-cli": "2.2.1", "@angular/core": "2.2.1", "@angular/forms": "2.2.1", "@angular/http": "2.2.1", "@angular/platform-browser": "2.2.1", "@angular/platform-browser-dynamic": "2.2.1", "@angular/platform-server": "2.2.1", "@ionic/storage": "1.1.7", "ionic-angular": "2.1.0", "ionic-native": "2.5.1", "ionicons": "3.0.0", "rxjs": "5.0.0-beta.12", "sw-toolbox": "3.4.0", "zone.js": "0.6.26" }, "devDependencies": { "@ionic/app-scripts": "1.1.4", "typescript": "2.0.9" }

This is why. Ionic storage has a dependency on 1.4 and on @types/localforage.

1 Like

uhm… indeed i was not tracking ionic-storage releases on github … added to my RSS feed
thanks! :slight_smile: i’will try tomorrow removing it, i don’t use it

so, the best solution seems to upgrade your @ionic/storage to 1.1.9

1 Like

Hi,

My version of ionic storage is “@ionic/storage”: “2.0.1” and the localForage version is 1.5.0 and still this issue, the only workaround is dowograde to 1.4 version?

This topic should no longer be relevant at all. @types/localforage isn’t used anymore.

Well i still prefer to use localForage instead of the crappy “Storage” wrapper