Skip to content

[js-client] Add tsc --noEmit to the js client test script and fix type error#885

Merged
samkim-crypto merged 2 commits intosolana-program:mainfrom
samkim-crypto:fix-js-type
Dec 9, 2025
Merged

[js-client] Add tsc --noEmit to the js client test script and fix type error#885
samkim-crypto merged 2 commits intosolana-program:mainfrom
samkim-crypto:fix-js-type

Conversation

@samkim-crypto
Copy link
Copy Markdown
Contributor

@samkim-crypto samkim-crypto commented Dec 9, 2025

Problem

If we current run pnpm tsc --noEmit on the js client, we get the following error:

test/_setup.ts:92:50 - error TS2345: Argument of type 'FullySignedTransaction & TransactionWithinSizeLimit & Readonly<{ messageBytes: TransactionMessageBytes; signatures: SignaturesMap; }> & TransactionWithLifetime' is not assignable to parameter of type 'FullySignedTransaction & TransactionWithinSizeLimit & Readonly<{ messageBytes: TransactionMessageBytes; signatures: SignaturesMap; }> & Omit<...> & { ...; }'.
  Type 'FullySignedTransaction & TransactionWithinSizeLimit & Readonly<{ messageBytes: TransactionMessageBytes; signatures: SignaturesMap; }> & TransactionWithLifetime' is not assignable to type '{ lifetimeConstraint: Omit<TransactionBlockhashLifetime, "blockhash">; }'.
    Types of property 'lifetimeConstraint' are incompatible.
      Type 'TransactionBlockhashLifetime | TransactionDurableNonceLifetime' is not assignable to type 'Omit<TransactionBlockhashLifetime, "blockhash">'.
        Property 'lastValidBlockHeight' is missing in type 'TransactionDurableNonceLifetime' but required in type 'Omit<TransactionBlockhashLifetime, "blockhash">'.

92   await sendAndConfirmTransactionFactory(client)(signedTransaction, {
                                                    ~~~~~~~~~~~~~~~~~

  node_modules/.pnpm/@solana+transactions@4.0.0_fastestsmallesttextencoderdecoder@1.0.22_typescript@5.9.3/node_modules/@solana/transactions/dist/types/lifetime.d.ts:25:5
    25     lastValidBlockHeight: Slot;
           ~~~~~~~~~~~~~~~~~~~~
    'lastValidBlockHeight' is declared here.


Found 1 error in test/_setup.ts:92

My understanding is that the sendAndConfirmTransactionFactory strictly requires a TransactionBlockhashLifetime. However, assertIsSendableTransaction types the variable as a FullySignedTransaction union, causing a type mismatch since the factory cannot handle nonce-based expiration.

Summary of Changes

I added assertIsTransactionWithBlockhashLifetime in test/_setup.ts to explicitly narrow the transaction type to one using a blockhash.

I updated the test script in package.json to run tsc --noEmit before ava to ensure test files are type-checked during builds/tests.

Copy link
Copy Markdown
Member

@grod220 grod220 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@samkim-crypto samkim-crypto merged commit 158acc9 into solana-program:main Dec 9, 2025
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants