Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add strict check for undefined properties on an object #357

Open
dib542 opened this issue May 2, 2023 · 0 comments
Open

Add strict check for undefined properties on an object #357

dib542 opened this issue May 2, 2023 · 0 comments

Comments

@dib542
Copy link
Collaborator

dib542 commented May 2, 2023

There is a common TypeScript issue where a property on an object is assumed to exists.

      // allUserTokensList is type Token[]
      const tokenIndex = allUserTokensList.findIndex(matchTokenDenom(denom));
      // token is of type Token not Token | undefined
      const token = allUserTokensList[tokenIndex];

This is a long and divisive issue in TypeScript microsoft/TypeScript#13778 because flagged all items found by index can be problematic in many places that they are expected to be known. However as a resolution, a --noUncheckedIndexedAccess flag can be used to turn on checking for this.

This has caused runtime errors in the past and I would prefer to be able to see these errors if feasible.

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

No branches or pull requests

1 participant