Skip to content

Commit a35c3a3

Browse files
authored
chore: throw error if ssz types for fork are not defined (#7850)
**Motivation** This makes debugging of ssz static spec tests easier as we print out the fork that is causing issues. Also as per type this function does not return `void` but in practice it happens due to missing check. **Description** Throw error if ssz types for fork are not defined
1 parent af28220 commit a35c3a3

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

packages/types/src/sszTypes.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@ export function sszTypesFor<F extends ForkName, K extends keyof SSZTypesByFork[F
6464
fork: F,
6565
typeName?: K
6666
): SSZTypesFor<F, K> {
67-
return (
68-
typeName === undefined ? typesByFork[fork] : typesByFork[fork][typeName as keyof SSZTypesByFork[F]]
69-
) as SSZTypesFor<F, K>;
67+
const sszTypes = typesByFork[fork];
68+
69+
if (sszTypes === undefined) {
70+
throw Error(`SSZ types for fork ${fork} are not defined`);
71+
}
72+
73+
return (typeName === undefined ? sszTypes : sszTypes[typeName as keyof SSZTypesByFork[F]]) as SSZTypesFor<F, K>;
7074
}

0 commit comments

Comments
 (0)