`Local.testAccounts` vs. `noUncheckedIndexAccess`
harrysolovay opened this issue · comments
With noUncheckedIndexedAccess
enabled (best practice), the TS checker errors on the inner destructuring of testAccount
elements.
let [{ privateKey, publicKey }] = Local.testAccounts
// ~~~~~~~~~~~~~~~~~~~~~~~~~
// ^
// Property 'privateKey' does not exist on type '{ publicKey: PublicKey; privateKey: PrivateKey; } | undefined'. ts(2339)
Is there a reason not to type the length of Local.testAccounts
? We could do so with the TupleN
type right here. This would spare the developer of needing to override the checker.
let [{ privateKey, publicKey }] = Local.testAccounts // no TS error, sweet!
Damn I didn't know noUncheckedIndexAccess
. I love it!