mathesar-foundation / mathesar

Web application providing an intuitive user experience to databases.
https://mathesar.org/
GNU General Public License v3.0
2.36k stars 327 forks source link

Improve type safety for array indexed access. #1966

Open seancolsen opened 1 year ago

seancolsen commented 1 year ago

Problem

In this code, myNumber has type number, when its runtime value is actually undefined:

const numbers = [3, 5, 7, 11, 13];
const myNumber = numbers[100];

This can lead to bugs, (example).

Potential solutions

@pavish and @rajatvijay I'm curious to hear your thoughts on which of the above approaches you might be interested in adopting, if any.

rajatvijay commented 1 year ago

I prefer option A since this is the most reliable one and can be enforced easily.

Adopting option B will lead to more conventions, one more thing to check while reviewing the PR. Also might get out of hand when we get more outside PRs.

Having said that: Since option A will take a LONGER time to implement, how about having a convention for option B for now and deprecating it when option A lands?

github-actions[bot] commented 1 year ago

This issue has not been updated in 90 days and is being marked as stale.