Skip to content

Check for accounts during connect logic - #26

Merged
tim-hm merged 1 commit into
NillionNetwork:mainfrom
envoy1084:main
Oct 7, 2024
Merged

tim-hm merged 1 commit into
NillionNetwork:mainfrom
envoy1084:main

Conversation

@envoy1084

Copy link
Copy Markdown
Contributor

This PR introduces a check for accounts[0] during connect logic for PaymentClient, which leads to typescript errors while building in strict mode.

This is because accounts is a array of AccountData and array indexing can lead to undefined typed value.

@tim-hm

tim-hm commented Oct 2, 2024

Copy link
Copy Markdown

Apologies was focused on another project the past few weeks. Will try and review this tomorrow. Thank you for your patience.

@tim-hm

tim-hm commented Oct 4, 2024

Copy link
Copy Markdown

Hi @Envoy-VC, I don't think noUncheckedIndexedAccess is enabled in strict mode [1] and [2]? Also given the code's structure accounts[0] will always be defined so I'm not totally sure the additional check is necessary? If this was arbitrary index access, like accounts[i] then yes I think this check would be necessary.

WDYT?

[1] microsoft/TypeScript#49169
[2] microsoft/TypeScript#39560

@envoy1084

Copy link
Copy Markdown
Contributor Author

Hi @Envoy-VC, I don't think noUncheckedIndexedAccess is enabled in strict mode [1] and [2]? Also given the code's structure accounts[0] will always be defined so I'm not totally sure the additional check is necessary? If this was arbitrary index access, like accounts[i] then yes I think this check would be necessary.

WDYT?

[1] microsoft/TypeScript#49169 [2] microsoft/TypeScript#39560

Yes I checked strict mode doesn't include it by default.
My project had noUncheckedIndexedAccess set to true so I wasn't able to build it.

I think it would be better it it was checked or else anyone would have to disable type checking in the project. for example, but yes it not necessary.

@tim-hm

tim-hm commented Oct 7, 2024 •

Copy link
Copy Markdown

I believe there is another place with unchecked access which I will update. I'll update our tsconfig and fix that in another PR. Thanks for your work 🙏

@tim-hm
tim-hm merged commit e9c0f69 into NillionNetwork:main Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

⌂ Proxy