apple-authentication
apple-authentication copied to clipboard
Convert JS code to TypeScript
Summary
Convert the index.js
file to TypeScript, and provide types and interfaces for all options, enums and returned objects.
This is part of the plan described in #2.
TODO
- [x] Add types to
SignInWithApple
(with all enums and sub-types) - [x] Add types to
SignInWithAppleButton
- [x] Create a build script to export
index.ts
toindex.js
andindex.d.ts
(tsc
with ES6 exports should be enough for now as the current JS code only exports as ES6 and no bundling is necessary) - [ ] Make sure everything is well exported when transpiled.
Test Plan
What's required for testing (prerequisites)?
- A React-Native project already setup with TypeScript
What are the steps to reproduce (after prerequisites)?
- Import this package and link it
- Use all features and make sure no type errors are popping up
- Make sure the module works as expected
Compatibility
(Not applicable)
Checklist
- [ ] I have tested this on a device and a simulator
- [ ] I added the documentation in
README.md
- [ ] I mentioned this change in
CHANGELOG.md
- [ ] I updated the typed files (TS and Flow)
- [ ] I added a sample use of the API in the example project (
example/App.js
)
As far as I could read the Objective-C implementation (which means "barely"), only the requestAsync
method is implemented on the SignInWithApple
object. Therefore, I didn't make the typings for the other methods documented in the README.
Also, is there a testing process already in place so that I can stick to it? How would I test the module in a blank project to make sure it works? Just point a package.json
dependency to my work folder?
I added a build
script to the package.json
, emitting an index.js
file. I kept the target to ES6, but it can be changed depending on what you want to ship to NPM.
Added the types for SignInWithAppleButton
.
I've experimented with TypeScript namespace
and module
to have a better way of handling the enums attached to the object, but it seems quite complex.
I also tried using TypeScript enum
, which is great since it provides both values and types, but since everything in this file is just types and interfaces declarations, and the actual "implementation" is done by NativeModules.RNCAppleAuthentication
and requireNativeComponent
, I can't really use them.
@matt-oakes @vonovak I would love some feedback on this. I'm not super familiar with the native bridge, so maybe I'm doing a few things wrong.
Also, if there is a specific testing process, I'd love to hear about it to make sure I test this right.
@thib92 hi and thanks for you time! Please stand by for now, we're not sure at this point if we're going to keep this repo or rely on Expo for apple auth. Thanks!
@vonovak thanks for the update. Please keep me posted 😄
@vonovak we don’t have Expo in our app, so… I’d love to move forwards with this library, & TypeScript. How can I help?
(I’ve made native modules, and our app is in TypeScript, and I’ve been writing objective-c since 2006)