Skip to content

Commit

Permalink
ts: Update types to work for vec and array (coral-xyz#862)
Browse files Browse the repository at this point in the history
  • Loading branch information
Arrowana authored Oct 10, 2021
1 parent a845af2 commit ee19059
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ts/src/program/namespace/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,10 @@ export type DecodeType<T extends IdlType, Defined> = T extends keyof TypeMap
? Defined[T["defined"]]
: T extends { option: { defined: keyof Defined } }
? Defined[T["option"]["defined"]] | null
: T extends { vec: { defined: keyof Defined } }
? Defined[T["vec"]["defined"]][]
: T extends { vec: keyof TypeMap }
? TypeMap[T["vec"]][]
: T extends { array: [defined: keyof TypeMap, size: number] }
? TypeMap[T["array"][0]][]
: unknown;

/**
Expand Down

0 comments on commit ee19059

Please sign in to comment.