Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export indy-sdk types #38

Closed
jakubkoci opened this issue Apr 17, 2020 · 3 comments
Closed

Export indy-sdk types #38

jakubkoci opened this issue Apr 17, 2020 · 3 comments

Comments

@jakubkoci
Copy link
Contributor

jakubkoci commented Apr 17, 2020

Re-export indy-sdk type or, better, move indy-sdk types into https://github.com/DefinitelyTyped/DefinitelyTyped project. I've tried it to move it into DefinitelyTyped, but our current format is not compatible with its linter.

The current solution caused me an issue when I tried to use the framework library within other TS project, as a workaround I created https://github.com/jakubkoci/types-indy-sdk which I'm adding to the project as dependency, but this should be just temporary solution.

@TimoGlastra TimoGlastra added this to the 0.1 milestone Jul 17, 2020
@TimoGlastra
Copy link
Contributor

TimoGlastra commented Nov 3, 2020

WIP @types/indy-sdk: https://www.npmjs.com/package/@types/indy-sdk
WIP aries-framework-javascript: https://github.com/TimoGlastra/aries-framework-javascript/tree/feature/external-indy-sdk-types

Still need to write tests for @types/indy-sdk.

As discussed on last working group call I'd write out the two approaches we can take for the types so that we can use types for both indy-sdk for NodeJS and for react-native.

1. Separate type definitions for indy-sdk and rn-indy-sdk

We will publish two type definitions to @types scope. We will also create two type definition directories in the DefinitelyTyped repo.

  • types/rn-indy-sdk will become @types/rn-indy-sdk
  • types/indy-sdk will become @types/indy-sdk

Downside is that we need to create to identical type definitions and will need to maintain both. This is also inconvenient when you want to use rn-indy-sdk and indy-sdk in a code base interchangeably.

2. Single type definition for indy-sdk, alias rn-indy-sdk

We will publish a single type definition to @types scope. We will also create a single type definition directory in the DefinitelyTyped repo.

  • types/indy-sdk will become @types/indy-sdk

When you want to use indy-sdk in react native you'd need to alias import of indy-sdk to rn-indy-sdk. This will also mean that you can use the same code in react native and NodeJS (no problem of needing to import rn-indy-sdk in react native and indy-sdk in NodeJS).

Downside is that you need to do some custom setup at the start of a react native project to rewrite the indy-sdk import to rn-indy-sdk. Back in the day this would be a tedious task, but today it will come down to installing babel-plugin-rewrite-require and adding the "indy-sdk": "rn-indy-sdk" alias. (See StackOverflow answer)

3. Separate type definitions for indy-sdk and rn-indy-sdk, but rn-indy-sdk imports and re-exports indy-sdk types.

Basically same approach as 1., but in this case we'd import @types/indy-sdk in @types/rn-indy-sdk and re-export it. I'm not 100% how this would work, but i'm almost certain it's possible.


All approaches listed above have one thing in common: we need to publish @types/indy-sdk to DefinitelyTyped. So for now I'd suggest I go ahead with that, create the PR in the DefinitelyTyped repo. Get the @types/indy-sdk package released and then update my aries-framework-javscript branch to use this. Then we can look if approach 2 is sufficient and if not release @types/rn-indy-sdk in the future. This will at least gives up proper typing for now, as current appraoch with the types in the repo really limits usage of the framework.

@jakubkoci, @karimStekelenburg input very welcome :)


TODO: Merge with types from AbsaOSS/rn-indy-sdk#26

@TimoGlastra
Copy link
Contributor

Decided on working group call to start with release of @types/indy-sdk and look at the exact approach to take later on.

@TimoGlastra
Copy link
Contributor

Indy types are now handled by @types/indy-sdk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants