You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ideally we could catch this in the type system, e.g. only allow the no-arg sort() for arrays of strings.
But I think you can't express that in the TS type system.
Maybe this is a good motivating example for some sort of fancier static analysis pass -- it needs to know the type of the variable to properly check.
The text was updated successfully, but these errors were encountered:
@martine says
https://influxdata.com/blog/the-chronograf-files-the-curious-case-of-javascripts-sort/
tldr array.sort() coerces to strings sorts lexicographically, you need to pass a comparator if you want otherwise.
Ideally we could catch this in the type system, e.g. only allow the no-arg sort() for arrays of strings.
But I think you can't express that in the TS type system.
Maybe this is a good motivating example for some sort of fancier static analysis pass -- it needs to know the type of the variable to properly check.
The text was updated successfully, but these errors were encountered: