Ionic 2 typescript definition


#1

I instlaled typescript for vim now and have some error message i cannot get rid of. namely:

/app/services/db-service.ts|14 col 28 error| Cannot find name 'device'.
/app/services/db-service.ts|19 col 29 error| Property 'connection' does not exist on type 'Navigator'.
/app/utils/auth/auth.ts|59 col 42 error| Property 'message' does not exist on type 'Response'.
/app/utils/auth/auth.ts|81 col 44 error| Property '_body' is private and only accessible within class 'Response'.
/app/app.ts|37 col 34 error| Cannot find name 'device'.
/node_modules/angular2/src/facade/promise.d.ts|1 col 10 error| Cannot re-export name that is not defined in the module.
/typings/browser/ambient/cordova-ionic/index.d.ts|10 col 12 error| Cannot find namespace 'Ionic'.

can anyone help me with them?

my typings.json

{
  "dependencies": {},
  "devDependencies": {},
  "ambientDependencies": {
    "cordova-ionic": "registry:dt/cordova-ionic#0.0.0+20160316155526",
    "es6-shim": "github:DefinitelyTyped/DefinitelyTyped/es6-shim/es6-shim.d.ts#4de74cb527395c13ba20b438c3a7a419ad931f1c",
    "localforage": "registry:dt/localforage#0.0.0+20160316155526"
  }
}

my tsconfig.json

  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true
  },
  "filesGlob": [
    "**/*.ts",
    "!node_modules/**/*"
  ],
  "exclude": [
    "node_modules",
    "typings/main",
    "typings/main.d.ts"
  ],
  "compileOnSave": false,
  "atom": {
    "rewriteTsconfig": false
  }
}

#2

I would lose the ‘ionic-cordova’ typings and look into installing ionic-native if you want that functionality. That will fix the bottom error. Upgrading angular2 past beta7 (beta13 is current now) will fix the error above that. The rest of them look like they’re in your code, and would be tough to discuss without seeing it. The one on line 81 of auth.ts is pretty self-explanatory, though. You are trying to access a private class member from outside the class. Not letting you do that is sort of the entire point of private members.


#3

Hello from another Vim user!

So there’s a few things

cordova-ionic from DT is for the V1 keyboard API. You do not need that.
In fact, the typings for ionic2 are already bundled with the framework. So you really don’t need set anything up for that. It should read the tsconfig and look at the definition files there.

@rapropos is half right. If you want to use the native cordova features, you can install ionic-native from npm

npm install ionic-native --save

This will give you the definitions for all the cordova plugin

http://ionicframework.com/docs/v2/native/Action%20Sheet/

As for the NG2, don’t upgrade NG2 yet. The recent ng2 beta release had many errors in them. A big reason why we didn’t update right away. We’re working on update to support beta13, which does include some changes as well that we need to address. At the moment, you can ignore the NG2 ts errors. They’re annoying, but won’t break anything.


#4

Can you point me at some issues that show what to look out for? I had this conversation with @brandyshea on GitHub and the only issue in that list that I saw that was related to Angular2 versions would have been fixed by moving past beta10. I will respect your wishes and stop recommending that people upgrade it, but I would strongly prefer not to roll back personally and it would be nice to know what known mines are lying in the field with respect to Ionic compatibility.


#5

thx for your input.

i was able to get rid of all the errors. sometimes the error

/node_modules/angular2/src/facade/promise.d.ts|1 col 10 error| Cannot re-export name that is not defined in the module.

occurs.

my typings.json looks like this now:

{
  "dependencies": {},
  "devDependencies": {},
  "ambientDependencies": {
    "cordova-ionic": "registry:dt/cordova-ionic#0.0.0+20160316155526",
    "es6-shim": "github:DefinitelyTyped/DefinitelyTyped/es6-shim/es6-shim.d.ts#4de74cb527395c13ba20b438c3a7a419ad931f1c",
    "localforage": "registry:dt/localforage#0.0.0+20160316155526",
    "phonegap": "registry:dt/phonegap#2.3.0+20160316155526"
  }
}

#6

This one is fine, you can ignore it for now.

@rapropos no issue to point to, just talk between the ionic team. Anytime we update the angular version, there’s always a chance something could break. I only suggest staying on the build we provide as a precaution. Basically “We guarantee this version of ionic2 works this version of ng2. Anything else, you’re on your own”


#7

I am using node-forge for RSA keypair generation in my ionic 2 application.
node-forge definition file I have installed through definitelytyped typings.
node-forge uses forge.bundle.js file for this keypair generation.

After I include node forge in my application Ionic2 application is not working and getting an error cannot find module './aes'


#8

Is there a reason you can’t use WebCrypto to do that?