-
Notifications
You must be signed in to change notification settings - Fork 28
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
fix: augmented type generation #747
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not too deep into all these JS/TS stuff, but it looks good. The only thing is that if I run yarn build
in the root and then yarn build:types
from within the augmentation package, the compiler still complains that src/interfaces/extraDefs/types.ts
cannot find the name PalletDidLookupLinkableAccountLinkableAccountId
, and in the diff I can see the old FIXME
is gone. Is that expected? Is it just my own VSCode compiler issue?
@@ -275,7 +275,7 @@ declare module '@polkadot/rpc-core/types/jsonrpc' { | |||
/** | |||
* Returns the number of transactions sent from given address at given time (block number). | |||
**/ | |||
getTransactionCount: AugmentedRpc<(hash: H256 | string | Uint8Array, number?: BlockNumber | AnyNumber | Uint8Array) => Observable<U256>>; | |||
getTransactionCount: AugmentedRpc<(address: H160 | string | Uint8Array, number?: BlockNumber | AnyNumber | Uint8Array) => Observable<U256>>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this auto-generated? Why do we have a change from AccountId32
to AccountId20
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah we haven't been able to run type generation on this polkadot version, so this has been outdated until now
packages/augment-api/index.cjs
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get a linter error that the header is missing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
weirdly, I don't ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added the header nevertheless
packages/augment-api/index.mjs
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
It's 'expected' - that we once introduced a manual fix to an autogenerated file means that we'll have to reapply this fix every time after autogeneration, which in most cases just means reverting the change to this line. |
* fix: api-augment type generation * fix: extraDefs subpath export * chore: run type generation * chore: add explanatory comments
* fix: api-augment type generation * fix: extraDefs subpath export * chore: run type generation * chore: add explanatory comments
fixes KILTProtocol/ticket#2576
We're not the only ones with that problem, and from issues on the polkadot-js/api repo I took that type augmentation can no longer be run in cjs. We are now required to add the
--esm
flag when callingts-node
and to add the"type":"module"
to the package.json. Fearing that this may interfere with the dual cjs/esm code generation in our repo, and realising we do not actually need code, just types from the augment-api package, I have refactored the build process only of this package to just produce types (and a few dummy files required for importing them from different environments.Along the way, I have also tackled two FIXMEs that we've had sitting there for a while now.
How to test:
I tried building and publishing with
yalc
and using the resulting package in stakeboard, which works fine. Could be tried in other projects using this package as well.Checklist: