diff --git a/packages/typegpu-gl/src/glslGenerator.ts b/packages/typegpu-gl/src/glslGenerator.ts index deb15ac312..cfc5811b9b 100644 --- a/packages/typegpu-gl/src/glslGenerator.ts +++ b/packages/typegpu-gl/src/glslGenerator.ts @@ -10,6 +10,7 @@ import { withValue, } from 'typegpu/~internal'; import type { + AutoStruct, ResolutionCtx, FunctionDefinitionOptions, ConstantDefinitionOptions, @@ -1010,13 +1011,7 @@ export class GlslGenerator extends WgslGenerator { // Is this an auto-detected output struct? If so, register each prop so the // output struct's propTypes reflects what the body actually returns. const isAutoStruct = expectedReturnType?.type === 'auto-struct'; - const autoStruct = isAutoStruct - ? (expectedReturnType as unknown as { - completeStruct: d.WgslStruct; - accessProp(key: string): { prop: string; type: d.BaseData } | undefined; - provideProp(key: string, type: d.BaseData): { prop: string; type: d.BaseData }; - }) - : undefined; + const autoStruct = isAutoStruct ? (expectedReturnType as unknown as AutoStruct) : undefined; // Resolve each RHS first so module-level references get reserved (and types become // available) before we allocate our LHS output identifiers. diff --git a/packages/typegpu/src/data/autoStruct.ts b/packages/typegpu/src/data/autoStruct.ts index 4fc745cccb..d08186bad5 100644 --- a/packages/typegpu/src/data/autoStruct.ts +++ b/packages/typegpu/src/data/autoStruct.ts @@ -35,6 +35,11 @@ export class AutoStruct implements BaseData, SelfResolvable { #cachedStruct: WgslStruct | undefined; #typeForExtraProps: BaseData | undefined; + static { + AutoStruct.prototype[$internal] = {}; + AutoStruct.prototype.type = 'auto-struct'; + } + constructor( validProps: Record, typeForExtraProps: BaseData | undefined, @@ -116,6 +121,3 @@ export class AutoStruct implements BaseData, SelfResolvable { return `auto-struct:${getName(this) ?? ''}`; } } - -AutoStruct.prototype[$internal] = {}; -AutoStruct.prototype.type = 'auto-struct'; diff --git a/packages/typegpu/src/internal.ts b/packages/typegpu/src/internal.ts index e817e56692..472380f7bb 100644 --- a/packages/typegpu/src/internal.ts +++ b/packages/typegpu/src/internal.ts @@ -26,6 +26,7 @@ export { // types export type { ResolutionCtx, FunctionArgument } from './types.ts'; export type { Snippet, ResolvedSnippet, Origin } from './data/snippet.ts'; +export type { AutoStruct } from './data/autoStruct.ts'; export type { ShaderGenerator,