Open
Conversation
Pull Request Test Coverage Report for Build 24003664370Details
💛 - Coveralls |
chrisgervang
approved these changes
Apr 5, 2026
chrisgervang
left a comment
There was a problem hiding this comment.
Can an application include a Float16Array polyfill and stay compatible with the compatibility layer added in this?
E.g. https://www.npmjs.com/package/@petamoriken/float16
Looks like the biggest gap is the 8% of users still on old versions of desktop chrome https://caniuse.com/mdn-javascript_builtins_float16array
I imagine we could remove the compatibility layer within a year or two at the rate this got adopted
| | Float64Array | ||
| | number[]; | ||
|
|
||
| // Conditionally include Float16Array without hard-referencing the global symbol. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
JS environments are finally introducing a standarized Float16Array type. This is a big deal for luma.gl/deck.gl given the big perf and memory advantages and the built-in support for float16 attributes in WebGPU and WebGL2.
This PR carefully adds support to math.gl types while making sure we don't break on older browsers.
Add environment-safe
Float16Arraysupport to math.gl types without hard-referencing the globalFloat16Arraysymbol.Changes:
TypedArrayandTypedArrayConstructorinmodules/types/src/array-types.tswith conditional float16 helper types that resolve toneverwhenFloat16Arrayis not defined by the current environment/type libs.modules/core/src/lib/gl-matrix.d.tsso the localNumericArraydeclaration stays aligned.modules/types/test/float16-types.tsto verify the conditional aliases work inTypedArrayandNumericArrayassignments.is-arraytest so it only constructs a float16 typed array whenglobalThis.Float16Arrayexists.Float16Arraysupport as conditional.Validation:
tsc -b modules/types/tsconfig.json modules/core/tsconfig.json --pretty falsetsc --noEmit --skipLibCheck --moduleResolution node --target es2020 --module es2020 modules/types/test/float16-types.tsocular-test node modules/types/test/index.ts