greggman / twgl.js

A Tiny WebGL helper Library
http://twgljs.org
MIT License
2.61k stars 258 forks source link

Incorrect TypeScript types of `createAugmentedTypedArray` #224

Closed sehilyi closed 11 months ago

sehilyi commented 11 months ago

I am using v5.4.0 and find that there are incorrect typescript types for createAugmentedTypedArray.

  1. The third parameter is required, i.e., opt_type, but it seems to be actually optional. This is inconsistent between

https://github.com/greggman/twgl.js/blob/a315ee85d8b2ead1e8c7f5972450fdd5ed847b66/dist/5.x/twgl-full.d.ts#L3712-L3718

(which is the file I get on my node_modules/twgl.js)

and

https://github.com/greggman/twgl.js/blob/a315ee85d8b2ead1e8c7f5972450fdd5ed847b66/npm/base/index.d.ts#L261

  1. The correct return type seems to be AugmentedTypedArray that has a push function attached, but it is defined as ArrayBufferView.

If you could share with me how I can update this, I can make a PR for that.

Thanks!

greggman commented 11 months ago

You can try v5.4.1

I'm not 100% sure createAugmentedTypedArray is compatible with typescript but a few simple tests seemed to work

sehilyi commented 11 months ago

I can confirm that the TS issue is addressed in v5.4.1. Thanks!!