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

refactor(experimental): WIP modify rpc types for performance #1759

Conversation

steveluscher
Copy link
Contributor

@steveluscher steveluscher commented Oct 21, 2023

This PR aims to improve the typechecking performance of the RPC types. See #1682 for more information.

This ‘get the overloads recursively with some trickery’ approach was borrowed from @Shakeskeyboarde here (playground). It's much faster, but it doesn't completely work.

We run into this error:

error TS2589: Type instantiation is excessively deep and possibly infinite

image.png

  1. Interfaces with as little as two overloads (eg. getBlockProduction) trigger that error, seemingly just because they are generic.
    getBlockProduction<TIdentity extends Base58EncodedAddress>(
        config: GetBlockProductionApiConfigBase &
            Readonly<{
                identity: TIdentity;
            }>
    ): GetBlockProductionApiResponseBase & GetBlockProductionApiResponseWithSingleIdentity<TIdentity>;
    Eliminate that type parameter and it compiles just fine.
    getBlockProduction(
        config: GetBlockProductionApiConfigBase &
            Readonly<{
                identity: Base58EncodedAddress;
            }>
    ): GetBlockProductionApiResponseBase & GetBlockProductionApiResponseWithSingleIdentity<Base58EncodedAddress>;
  2. Interfaces with many overloads (eg. getBlock) also trigger it, but for what reason I don't know (ie. I'm not sure if it's because of the quantity of overloads, or because of some feature of their method signatures).

How to test this

pnpm i
pnpm turbo test:typecheck

@steveluscher
Copy link
Contributor Author

Current dependencies on/for this PR:

This comment was auto-generated by Graphite.

@steveluscher
Copy link
Contributor Author

Chris (@Shakeskeyboarde), do you have any ideas here, having written the original utility type?

@nmn, any thoughts on this?

@steveluscher steveluscher force-pushed the 10-21-refactor_experimental_WIP_modify_rpc_types_for_performance branch from 16dc368 to 09443fa Compare October 21, 2023 21:06
@steveluscher steveluscher deleted the 10-21-refactor_experimental_WIP_modify_rpc_types_for_performance branch October 22, 2023 06:09
@nmn
Copy link

nmn commented Oct 25, 2023

@steveluscher Sorry was swamped for a couple of days. I don't think this went far enough, so I can see you closed it.

@steveluscher
Copy link
Contributor Author

I don't think this went far enough, so I can see you closed it.

Not at all! Thanks for taking a look. I just closed it because I slam dunked it in #1760. And by slam dunked it I mean I slammed a sandwich in a car door and magically the bug disappeared.

Copy link
Contributor

github-actions bot commented Nov 8, 2023

Because there has been no activity on this PR for 14 days since it was merged, it has been automatically locked. Please open a new issue if it requires a follow up.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants