Closed steveluscher closed 3 months ago
This error seems to also occur with the setTransactionMessageFeePayer
function.
import {
CompilableTransactionMessage,
setTransactionMessageFeePayer,
} from "@solana/web3.js";
const payer = null as unknown as Address;
const compilableMessage = null as unknown as CompilableTransactionMessage;
setTransactionMessageFeePayer(payer, compilableMessage);
Whilst CompilableTransactionMessage
satisfies BaseTransactionMessage
, I think TypeScript isn't able to resolve infer the TTransaction
type parameter properly using the following signature:
export function setTransactionMessageFeePayer<
TFeePayerAddress extends string,
TTransaction extends BaseTransactionMessage,
>(
feePayer: Address<TFeePayerAddress>,
transaction: TTransaction | (ITransactionMessageWithFeePayer<string> & TTransaction),
): ITransactionMessageWithFeePayer<TFeePayerAddress> & TTransaction;
The following change seems to make TypeScript happy but I guess by doing this we are no longer telling TS to remove the existing ITransactionMessageWithFeePayer
flag if any exists.
export function setTransactionMessageFeePayer<
TFeePayerAddress extends string,
TTransaction extends BaseTransactionMessage,
>(
feePayer: Address<TFeePayerAddress>,
- transaction: TTransaction | (ITransactionMessageWithFeePayer<string> & TTransaction),
+ transaction: TTransaction,
): ITransactionMessageWithFeePayer<TFeePayerAddress> & TTransaction;
EDIT: perhaps something like this could do the trick?
export function setTransactionMessageFeePayer<
TFeePayerAddress extends string,
TTransaction extends BaseTransactionMessage,
>(
feePayer: Address<TFeePayerAddress>,
transaction: TTransaction,
): TTransaction extends ITransactionMessageWithFeePayer<string>
? ITransactionMessageWithFeePayer<TFeePayerAddress> & Omit<TTransaction, 'feePayer'>
: ITransactionMessageWithFeePayer<TFeePayerAddress> & TTransaction;
EDIT: perhaps something like this could do the trick?
Yeah, that 100% works. I'll PR that.
:tada: This issue has been resolved in version 1.95.0 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
Because there has been no activity on this issue for 7 days since it was closed, it has been automatically locked. Please open a new issue if it requires a follow up.
Sandbox link