-
Notifications
You must be signed in to change notification settings - Fork 725
Open
Description
- With
noUncheckedIndexAccess
enabled, TypeScript gives the wrong types when destructuring:
function doSomething([x, y]: ReadonlyVec2) {
console.log(x + y); // error: typeof x = number | undefined
}
- TypeScript doesn't throw errors when it "should":
function doSomething([x, y, z]: ReadonlyVec2) {
// ^^ should be type error!
}
Related: #381.
At Datadog, we've built our "solution": we used yarn patch
to simply erase Float32Array
as a type. TypeScript now treats gl-matrix objects as tuples.
The downside: without accepting Float32Array
, it's hard to cast Float32Array
to vec2
. That's no problem if callers only use vec2.create()
and vec2.fromValues()
. But it's a problem if callers are allocating a Float32Array themselves and doing vector math on slices of it.
Metadata
Metadata
Assignees
Labels
No labels