naoufal / react-native-touch-id

React Native authentication with the native Touch ID popup.
https://www.npmjs.com/package/react-native-touch-id
1.47k stars 476 forks source link

Added typescript definition file #178

Closed Aidurber closed 5 years ago

Aidurber commented 5 years ago

I had a nasty crash because I had a typo, so I made a TypeScript definition file. I thought it would be useful for other users, too.

Note that in when you're in a try catch, the catch clause variable cannot have a type annotation.

You can cast the error:

// try...
catch (e) {
 const err = e as AuthenticationError;
 if(err.code === "NOT_AVAILABLE"){
    console.log('err')
 }
}

And you get nice intellisense for your errors:

screenshot 2018-11-09 13 50 46

Let me know what you think.

zibs commented 5 years ago

Hey this looks awesome! I'll take a closer look later, and happily bring it in if so!

zibs commented 5 years ago

@Aidurber just one change and we're good!

zibs commented 5 years ago

Thanks!

zibs commented 5 years ago

🎉