From 86c39782942422680e3e1777aa83c192cec18092 Mon Sep 17 00:00:00 2001 From: Yuri Date: Tue, 19 Nov 2024 21:50:22 +0100 Subject: [PATCH] Better Object type merging with default provided type fix this issue: ``` import { type Transaction as _Transaction, } from '@subsquid/evm-processor'; export const processor = new EvmBatchProcessor() .addTransaction({ type: [4], }) .setFields({ log: { transactionHash: true }, transaction: { authorizationList: true, }, }); export type Fields = EvmBatchProcessorFields; export type TransactionWithFields = _Transaction; fn(transaction: TransactionWithFields) { console.log(transaction.authorizationList) // Type is now correctly inferred } ``` --- evm/evm-processor/src/interfaces/data.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/evm/evm-processor/src/interfaces/data.ts b/evm/evm-processor/src/interfaces/data.ts index 4b5a6a6a1..3aaa509e6 100644 --- a/evm/evm-processor/src/interfaces/data.ts +++ b/evm/evm-processor/src/interfaces/data.ts @@ -86,9 +86,10 @@ type ExcludeUndefined = { type MergeDefault = Simplify< - undefined extends T ? D : Omit> & ExcludeUndefined -> - + T extends Object + ? Omit> & T + : D +>; type TrueFields = keyof { [K in keyof F as true extends F[K] ? K : never]: true