Closed callensm closed 11 months ago
It is because of: https://github.com/project-serum/anchor/blob/master/ts/src/program/namespace/account.ts#L46 and https://github.com/project-serum/anchor/blob/master/ts/src/program/namespace/account.ts#L76
which are saying that the type if an arbitrary index of the accounts array in the IDL, allow the type definition to become the union of all available.
probably for the same reason, program.methods.accounts({ .. })
is also not typed properly
the MethodsBuilder.accounts
function typings should have been fixed in a PR I submitted about a month ago.
it it fixed for you? its not working for me
ahhh, it works as expected as a chain onto the instruction, e.g.:
program
.methods
.initAccount()
.accounts({ ... })
// ...
but using it prior to the instruction would cause issues because the typings don't know which instruction has been selected yet to pull the account names for.
Querying for accounts like
program.account.myAccount.fetch(addr)
should return an object that is strictly typed for themyAccount
account type definition.However, the client currently types the object as being the union of properties between all IDL defined account structs.
As seen in the screenshot, the typing on the
listing
account client includes the properties of other account types.