fix: Add a catch-all overload for root.createBuffer#2339
fix: Add a catch-all overload for root.createBuffer#2339
Conversation
|
pkg.pr.new packages benchmark commit |
📊 Bundle Size Comparison
👀 Notable resultsStatic test results:No major changes. Dynamic test results:No major changes. 📋 All resultsClick to reveal the results table (349 entries).
If you wish to run a comparison for other, slower bundlers, run the 'Tree-shake test' from the GitHub Actions menu. |
There was a problem hiding this comment.
Pull request overview
This PR adds a catch-all overload to the createBuffer method that accepts a union type for the second parameter, allowing either a callback function or raw data to be passed in. This enables better support for union types needed by @typegpu/react.
Changes:
- Added
NoInfer<TData>wrapper to the callback parameter in the firstcreateBufferoverload (line 839) with an explanatory comment - Added a new catch-all overload (lines 846-850) that accepts a union type combining both the callback and data initialization patterns
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
f5f982d to
13ff013
Compare
28fb12e to
6fbe735
Compare
| createBuffer<TData extends AnyData>( | ||
| typeSchema: ValidateBufferSchema<TData>, | ||
| initializer: (buffer: TgpuBuffer<TData>) => void, | ||
| // NoInfer is there to infer the schema type just based on the first parameter |
There was a problem hiding this comment.
I feel like the purpose is known at this point
There was a problem hiding this comment.
Yet we still forget 👴
6fbe735 to
8b4d265
Compare
This allows a union type to be passed into
createBuffer, which is something I need for@typegpu/react