Skip to content

fix: Export AutoStruct type from 'typegpu/~internal' - #2936

Open
iwoplaza wants to merge 1 commit into
mainfrom
fix/export-auto-struct
Open

fix: Export AutoStruct type from 'typegpu/~internal'#2936
iwoplaza wants to merge 1 commit into
mainfrom
fix/export-auto-struct

Conversation

@iwoplaza

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI lite review requested due to automatic review settings August 27, 2026 13:03
@github-actions

github-actions Bot commented Aug 27, 2026

Copy link
Copy Markdown

pkg.pr.new

packages
Ready to be installed by your favorite package manager ⬇️

https://pkg.pr.new/software-mansion/TypeGPU/typegpu@9cbb7b2e849da5479fa5c756b9344e6da4887eea
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/gl@9cbb7b2e849da5479fa5c756b9344e6da4887eea

benchmark
view benchmark

commit
view commit

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 AutoStruct as a type from packages/typegpu/src/internal.ts.
  • Updated packages/typegpu-gl/src/glslGenerator.ts to use the AutoStruct type 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.

Comment thread packages/typegpu-gl/src/glslGenerator.ts Outdated
@github-actions

github-actions Bot commented Aug 27, 2026

Copy link
Copy Markdown

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]
Loading
---
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]
Loading
---
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]
Loading

@github-actions

github-actions Bot commented Aug 27, 2026

Copy link
Copy Markdown

Bundle size comparison (import * as ... in PR vs import * as ... in target):

🟢 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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Type-level refactor of the auto-struct cast in glslGenerator.ts#handleStructReturn now imports AutoStruct from typegpu/~internal and replaces the inline anonymous structural type on the as unknown as cast, which previously duplicated completeStruct/accessProp/provideProp signatures.
  • Export AutoStruct from the ~internal barrel — adds export type { AutoStruct } from './data/autoStruct.ts'; to the // types group in packages/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.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@iwoplaza
iwoplaza force-pushed the fix/export-auto-struct branch 2 times, most recently from ac59de6 to 6bfd181 Compare August 27, 2026 13:59

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Moved AutoStruct prototype wiring into a static {} block — the [$internal] = {} / type = 'auto-struct' assignments previously sitting at the bottom of data/autoStruct.ts now live in a static {} initializer inside the class, matching the established idiom used across the codebase. Behavior is identical; ES2024 target supports static blocks.
  • Simplified the isAutoStruct check in glslGenerator.ts — the as unknown as AutoStruct cast was dropped from the type check (it only reads .type), keeping the cast only where the AutoStruct API is actually exercised. #handleStructReturn and 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.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@iwoplaza
iwoplaza force-pushed the fix/export-auto-struct branch from 6bfd181 to 9cbb7b2 Compare August 31, 2026 09:35

@cieplypolar cieplypolar left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure 🚢 🇮🇹

@aleksanderkatan aleksanderkatan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

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.

5 participants