Skip to content

feat(typescript): add generics to src/random functions to properly infer TypedArray - #39

Open
mgcrea wants to merge 2 commits into
pmndrs:mainfrom
mgcrea:feat-infer-typedarray
Open

feat(typescript): add generics to src/random functions to properly infer TypedArray#39
mgcrea wants to merge 2 commits into
pmndrs:mainfrom
mgcrea:feat-infer-typedarray

Conversation

@mgcrea

@mgcrea mgcrea commented Nov 16, 2023

Copy link
Copy Markdown

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-bot

changeset-bot Bot commented Nov 16, 2023

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: aa4a1ba

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

@vercel

vercel Bot commented Nov 16, 2023

Copy link
Copy Markdown

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

@codesandbox-ci

codesandbox-ci Bot commented Nov 16, 2023

Copy link
Copy Markdown

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 aa4a1ba:

Sandbox Source
maath-demo-circumcircle Configuration
maath-demo-points Configuration
maath-demo-sutherland-hodgman Configuration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant