feat(typescript): add generics to src/random functions to properly infer TypedArray
Hey! Thanks for the great lib,
Encountered a few TypeScript issues while using the library with @react-three/drei where props expects a Float32Array.
For instance the following code does not work currently (fails with Argument of type '() => TypedArray' is not assignable to parameter of type 'Float32Array | (() => Float32Array)'.), however the return type should easily be inferred with generics, hence this PR.
const [sphere] = useState<Float32Array>(() =>
random.inSphere(new Float32Array(5000), { radius: 1.5 }),
);
🦋 Changeset detected
Latest commit: aa4a1baa025d9af6a0ace87c8f36ab975734cd26
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 1 package
| Name | Type |
|---|---|
| maath | Patch |
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
The latest updates on your projects. Learn more about Vercel for Git ↗︎
| Name | Status | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| maath | ❌ Failed (Inspect) | Nov 16, 2023 8:59pm |
This pull request is automatically built and testable in CodeSandbox.
To see build info of the built libraries, click here or the icon next to each commit SHA.
Latest deployment of this branch, based on commit aa4a1baa025d9af6a0ace87c8f36ab975734cd26:
| Sandbox | Source |
|---|---|
| maath-demo-circumcircle | Configuration |
| maath-demo-points | Configuration |
| maath-demo-sutherland-hodgman | Configuration |