fix: Export AutoStruct type from 'typegpu/~internal' - #2936
Conversation
|
pkg.pr.new packages benchmark commit |
There was a problem hiding this comment.
Pull request overview
This PR exposes the AutoStruct type via the typegpu/~internal entrypoint so downstream packages (notably typegpu-gl) can reference it without importing from deep internal paths.
Changes:
- Exported
AutoStructas a type frompackages/typegpu/src/internal.ts. - Updated
packages/typegpu-gl/src/glslGenerator.tsto use theAutoStructtype for the auto-struct return handling cast.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/typegpu/src/internal.ts | Adds a type re-export for AutoStruct through typegpu/~internal. |
| packages/typegpu-gl/src/glslGenerator.ts | Uses the exported AutoStruct type to simplify the auto-struct cast/usage in struct-return handling. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Resolution Time Benchmark---
config:
themeVariables:
xyChart:
plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
title "Random Branching (🔴 PR | 🔵 main | 🟢 release)"
x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
y-axis "time (ms)"
line [0.90, 1.74, 3.72, 5.58, 6.93, 10.39, 21.80, 23.49]
line [0.86, 1.72, 3.75, 5.87, 6.89, 11.44, 25.13, 21.21]
line [0.80, 1.70, 3.49, 6.06, 6.81, 10.40, 21.15, 23.52]
---
config:
themeVariables:
xyChart:
plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
title "Linear Recursion (🔴 PR | 🔵 main | 🟢 release)"
x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
y-axis "time (ms)"
line [0.28, 0.48, 0.68, 0.76, 1.04, 1.11, 1.29, 1.47]
line [0.33, 0.51, 0.66, 0.72, 0.98, 1.01, 1.22, 1.40]
line [0.31, 0.51, 0.65, 0.74, 0.99, 0.98, 1.24, 1.32]
---
config:
themeVariables:
xyChart:
plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
title "Full Tree (🔴 PR | 🔵 main | 🟢 release)"
x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
y-axis "time (ms)"
line [0.88, 2.27, 3.56, 6.53, 12.15, 24.42, 51.37, 104.39]
line [0.94, 2.24, 3.39, 6.43, 11.03, 23.27, 50.63, 101.95]
line [0.82, 2.00, 2.89, 5.99, 10.87, 23.79, 50.14, 103.69]
|
Bundle size comparison (
|
| 🟢 Decreased | ➖ Unchanged | 🔴 Increased (max 0.01%) | ❔ Unknown |
|---|---|---|---|
| 0 | 312 | 13 | 0 |
No notable changes.
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.
✅ No new issues found.
Reviewed changes
- Type-level refactor of the auto-struct cast in
glslGenerator.ts—#handleStructReturnnow importsAutoStructfromtypegpu/~internaland replaces the inline anonymous structural type on theas unknown ascast, which previously duplicatedcompleteStruct/accessProp/providePropsignatures. - Export
AutoStructfrom the~internalbarrel — addsexport type { AutoStruct } from './data/autoStruct.ts';to the// typesgroup inpackages/typegpu/src/internal.ts.
The swap is type-equivalent: AutoStruct (in packages/typegpu/src/data/autoStruct.ts) exposes accessProp, provideProp, and completeStruct with signatures identical to the removed inline type, and it's only ever used under an as unknown as cast, so no runtime behavior changes. I verified pnpm --filter typegpu test:types, pnpm --filter @typegpu/gl test:types, and oxlint on both changed files all pass. Nice cleanup — removing the duplicated structural type makes the GLSL generator align with the actual AutoStruct API.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
ac59de6 to
6bfd181
Compare
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Moved
AutoStructprototype wiring into astatic {}block — the[$internal] = {}/type = 'auto-struct'assignments previously sitting at the bottom ofdata/autoStruct.tsnow live in astatic {}initializer inside the class, matching the established idiom used across the codebase. Behavior is identical; ES2024 target supports static blocks. - Simplified the
isAutoStructcheck inglslGenerator.ts— theas unknown as AutoStructcast was dropped from the type check (it only reads.type), keeping the cast only where theAutoStructAPI is actually exercised.#handleStructReturnand the input-side path are unaffected at runtime.
Type semantics are unchanged from the previously approved revision. Verified pnpm --filter typegpu test:types and pnpm --filter @typegpu/gl test:types both pass.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
6bfd181 to
9cbb7b2
Compare

No description provided.