Add typescript definitions for ethjs-util methods#248
Conversation
|
This is still draft...do you have any advice about what direction this should go in, if any.. 🙂 |
|
I will leave this to @s1na to make a comment here since he started the issue. From my side this looks like a good start. |
|
I've now excluded this from the |
|
Hm also not sure what's the best approach. I guess having the typedefs locally is okay since their repo hasn't changed much in the last 2 years. Ideally they'd merge these typedefs upstream and do a release. Or having these as under a types package as you suggested. We could also consider "forking" their code (if licenses are compatible) locally into the repo. |
tsconfig.json
Outdated
| { | ||
| "extends": "@ethereumjs/config-tsc", | ||
| "include": ["src/**/*.ts", "test/**/*.ts"] | ||
| "include": ["src/**/*.ts", "test/**/*.ts", "typings/**/*.js"] |
There was a problem hiding this comment.
I think this is typo.
- "typings/**/*.js"
+ "typings/**/*.ts"There was a problem hiding this comment.
I suggest that the another approach.
compileOptions.typeRoots's default value is @types.
So make below folders and put ethjs-util.d.ts to index.d.ts.
You don't need to modify tsconfig.json
- src
- @types
- ethjs-util
- index.d.ts
There was a problem hiding this comment.
@tomonari Thanks so much for catching this! Makes sense.
There was a problem hiding this comment.
@tomonari Unfortunately, fixing the typo does not seem to resolve the requirement that ethjs-util be imported at the top of index.ts with a path reference comment.
Also had no luck with your suggestion about adding @types folder in src. Maybe something strange is going on with extending the ethereumjs config, idk.
There was a problem hiding this comment.
@cgewecke
Thanks for trying it.
I also tried and find out that it is not caused of ts but karma-typescript.
I'm dealing with it.
There was a problem hiding this comment.
@cgewecke
I made example code. Please check tomonari-t#2.
There was a problem hiding this comment.
Yes that works! Have made your suggested changes in 40ecfe9 and added you as the commit author. Thank you for investigating this.
|
@s1na |
7bb802f to
c5ee67f
Compare
|
This pull request introduces 1 alert when merging c5ee67f into 58c2476 - view on LGTM.com new alerts:
|
c5ee67f to
40ecfe9
Compare
|
@cgewecke @tomonari-t just discovered on some experimentation around #257 that the changes on the Can you have a look here and open a PR fixing this? |
|
@holgerd77 Sorry about this. Have opened #260 which I think fixes. |
Attempt to resolve #219 by defining types for ethjs-util locally. Not certain this is the right approach, perhaps it should be done by publishing an @types module.
We should also probably extend the tests to validate the types themselves.
For reference, the ethjs-utils methods are defined here.