Replies: 1 comment 2 replies
-
I wonder if Civet is the right level to fix this. Fundamentally, it's a TS lib issue. So I wonder if it makes more sense to override the es2022 lib that introduced At a practical level, it's hard for Civet to fix this, because it would need to know the type of |
Beta Was this translation helpful? Give feedback.
2 replies
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
-
By what I would consider a series of historical accidents, in TypeScript, if$\mathbb Z_n$ .
A
is of typeT[]
andn
is of typenumber
thenA[n]
is of type number butA.at(n)
is of type number|undefined. It's as though TypeScript thinks that "ooh, negative numbers are hard, you're much more likely to mess up your indexing with at." So as a result I end up with ugly type assertions or lots ofor DummyT
s all over my code in places where it's convenient to work with negative indices, such as when the elements are naturally indexed byAny chance Civet could/would translate
A.at(n)
to(A.at(n) as T)
? (Any reason that would be a really bad idea? I couldn't see one, which is why I posted.)Beta Was this translation helpful? Give feedback.
All reactions