-
Notifications
You must be signed in to change notification settings - Fork 86
fix(types): remove @ts-ignore with proper type annotations #260
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
base: master
Are you sure you want to change the base?
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.
Removed @ts-ignore by fixing the root cause. factory functions were using overly complex cluster generics. Since they only require specific RPC API interfaces.
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.
question: by removing the generics doesn't this just mean we have less useful types? why is this a better solution?
Why We Removed GenericsUsing too many generics made the types harder to read, harder to maintain, and in some cases even caused TypeScript errors. In practice, the functions only needed the specific RPC API interfaces, not the extra cluster generics. By removing those unnecessary generics:
ExampleBefore (with cluster generics): type FactoryConfig<TCluster extends "mainnet" | "devnet" | "testnet"> = {
rpc: Rpc<APIs> & { "~cluster"?: TCluster };
}; After (with only the needed RPC APIs): type FactoryConfig = {
rpc: Rpc<GetEpochInfoApi & SendTransactionApi & ...>;
}; why better
Bottom LineNo useful type information was lost. What was removed was unused complexity:
plz review it once and suggest changes if required and anything more i should look towards |
// @ts-ignore - TODO(FIXME) | ||
const sendAndConfirmTransaction = sendAndConfirmTransactionFactory({ rpc, rpcSubscriptions }); | ||
}: SendAndConfirmTransactionWithSignersFactoryConfig): SendAndConfirmTransactionWithSignersFunction { | ||
const sendAndConfirmTransaction = sendAndConfirmTransactionFactory({ |
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.
curious on your thought process here? does this make it possible to pass a devnet rpc with mainnet subscriptions etc?
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.
@catmcgee you're right that this technically allows network mismatches. However, the previous code had the same issue - the @ts-ignore comments were bypassing all type checking including network validation. i will fix it and enforce that RPC and RpcSubscriptions must use the same network type . Anything else i should do .
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.
@lalitcap23 This comment feels partly AI generated to me #260 (comment).
Why can't we have the SendAndConfirmTransactionWithSignersFactoryConfig function where the generics work per cluster and the usage gets the correct types?
Also, you have modified several files in this PR with only white space changes unrelated to this PR. Please remove those changes.
Problem
Several
@ts-ignore
comments were used to bypass TypeScript errors.This reduced type safety and introduced technical debt.
The affected files are core to RPC client creation and transaction handling, making type correctness critical.
Summary of Changes
@ts-ignore
comments.📁 Changes in Files
create-solana-client.ts
@ts-ignore
comments.📁 Changes in File: send-and-confirm-transaction-with-signers.ts
@ts-ignore
comment.Verification
pnpm build
completes successfully.fixes #259