Skip to content
This repository has been archived by the owner on Jan 11, 2022. It is now read-only.

Missing type exports: RLPInput, RLPDecoded #58

Closed
webmaster128 opened this issue Dec 19, 2018 · 8 comments
Closed

Missing type exports: RLPInput, RLPDecoded #58

webmaster128 opened this issue Dec 19, 2018 · 8 comments

Comments

@webmaster128
Copy link
Contributor

The types RLPInput, RLPDecoded cannot be used in caller code because the index.d.ts does not export them.

A workaround is

// tslint:disable-next-line:no-submodule-imports
import { RLPInput } from "rlp/dist/types";

Having the types available is needed when you want to build a wrapper in TS like

export function toRlp(data: RLPInput): Uint8Array {
  const dataBuffer = rlp.encode(data);
  return Uint8Array.from(dataBuffer);
}
@holgerd77
Copy link
Member

//cc @krzkaczor Can you have a look?

@holgerd77
Copy link
Member

Not sure, do we want to expose these?

@webmaster128 TBH I find this use case not super convincing, do you really need a wrapper for this one extra call?

@webmaster128
Copy link
Contributor Author

@holgerd77 Yes I do in order to consistently use Uint8Array for my binary data.

But the more interesting question is: should you export function without exporting its argument or return types? Looks like to is possible but this approach is not convincing in my eyes.

@webmaster128
Copy link
Contributor Author

By the way, unprefixing them would be nice to allow consistency when importing

import * as rlp from "rlp";

// use rlp.encode, rlp.encode, rlp.Input, rlp.Decoded

@holgerd77
Copy link
Member

I'll wait for the answers from @krzkaczor, he is the TypeScript expert! 😄

@holgerd77
Copy link
Member

I actually think it make sense what you propose on a second thought - also the unprefixing. If you would manage to do a short-term PR on this I would merge and can probably directly release tomorrow along a necessary bugfix release planned.

@krzkaczor
Copy link
Contributor

I agree that exporting these types is a good idea @webmaster128 @holgerd77. Btw. It's great that we already have some typescript users ❤️

I think we should simply add export * from "./types"; in index.ts.

@webmaster128
Copy link
Contributor Author

If you would manage to do a short-term PR on this

Yeah, no problem. This is not urgent for me but I can have a look.

Btw. It's great that we already have some typescript users heart

Sure :) Just upgraded 2.1 to 2.2 and am very happy to get rid of the safe-buffer type which I cannot directly convert to Uint8Array doe to missing interfaces.

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

No branches or pull requests

3 participants