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

TypeScript array index access correctness #5

Open
Silic0nS0ldier opened this issue Jul 9, 2021 · 2 comments
Open

TypeScript array index access correctness #5

Silic0nS0ldier opened this issue Jul 9, 2021 · 2 comments

Comments

@Silic0nS0ldier
Copy link
Owner

Arrays in TypeScript have a rather significant coverage defect, their index type [n: number]: T; doesn't accurately reflect a given array.

Suppose you have an empty array of type string. For any given index, every value is going to be undefined.

Some arrays are special cases (as const) which are generally safer, but on the whole an arbitrary array has a massive untyped surface.

Within this repo array types should be augmented to ensure values from arbitrary indexes are checked, outside it would be worthwhile seeing if TypeScript might change this via a new strict check.

@Silic0nS0ldier
Copy link
Owner Author

Nevermind microsoft/TypeScript#13778

@Silic0nS0ldier Silic0nS0ldier changed the title TypeScript array index issues TypeScript array index access correctness Jul 9, 2021
@Silic0nS0ldier
Copy link
Owner Author

"noUncheckedIndexedAccess": true,

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