1- import type { AnyData } from '../../data/dataTypes.ts' ;
21import type { ResolvedSnippet } from '../../data/snippet.ts' ;
32import { schemaCallWrapper } from '../../data/schemaCallWrapper.ts' ;
4- import { Void } from '../../data/wgslTypes.ts' ;
3+ import { type BaseData , Void } from '../../data/wgslTypes.ts' ;
54import { ExecutionError } from '../../errors.ts' ;
65import { provideInsideTgpuFn } from '../../execMode.ts' ;
76import type { TgpuNamable } from '../../shared/meta.ts' ;
@@ -51,8 +50,8 @@ import type { Withable } from '../root/rootTypes.ts';
5150 * Describes a function signature (its arguments and return type)
5251 */
5352type TgpuFnShellHeader <
54- Args extends AnyData [ ] ,
55- Return extends AnyData ,
53+ Args extends BaseData [ ] ,
54+ Return extends BaseData ,
5655> = {
5756 readonly [ $internal ] : true ;
5857 readonly argTypes : Args ;
@@ -66,8 +65,8 @@ type TgpuFnShellHeader<
6665 * and passing the implementation (as WGSL string or JS function) as the argument.
6766 */
6867export type TgpuFnShell <
69- Args extends AnyData [ ] ,
70- Return extends AnyData ,
68+ Args extends BaseData [ ] ,
69+ Return extends BaseData ,
7170> =
7271 & TgpuFnShellHeader < Args , Return >
7372 & ( < T extends ( ...args : InferArgs < Args > ) => Infer < Return > > (
@@ -89,7 +88,7 @@ interface TgpuFnBase<ImplSchema extends AnyFn>
8988 readonly resourceType : 'function' ;
9089 readonly shell : TgpuFnShellHeader <
9190 Parameters < ImplSchema > ,
92- Extract < ReturnType < ImplSchema > , AnyData >
91+ Extract < ReturnType < ImplSchema > , BaseData >
9392 > ;
9493 readonly [ $providing ] ?: Providing | undefined ;
9594
@@ -102,22 +101,22 @@ export type TgpuFn<ImplSchema extends AnyFn = (...args: any[]) => any> =
102101 & TgpuFnBase < ImplSchema > ;
103102
104103export function fn <
105- Args extends AnyData [ ] | [ ] ,
104+ Args extends BaseData [ ] | [ ] ,
106105> ( argTypes : Args , returnType ?: undefined ) : TgpuFnShell < Args , Void > ;
107106
108107export function fn <
109- Args extends AnyData [ ] | [ ] ,
110- Return extends AnyData ,
108+ Args extends BaseData [ ] | [ ] ,
109+ Return extends BaseData ,
111110> ( argTypes : Args , returnType : Return ) : TgpuFnShell < Args , Return > ;
112111
113112export function fn <
114- Args extends AnyData [ ] | [ ] ,
115- Return extends AnyData = Void ,
113+ Args extends BaseData [ ] | [ ] ,
114+ Return extends BaseData = Void ,
116115> ( argTypes : Args , returnType ?: Return | undefined ) : TgpuFnShell < Args , Return > {
117116 const shell : TgpuFnShellHeader < Args , Return > = {
118117 [ $internal ] : true ,
119118 argTypes,
120- returnType : returnType ?? Void as Return ,
119+ returnType : returnType ?? Void as unknown as Return ,
121120 isEntry : false ,
122121 } ;
123122
@@ -133,7 +132,7 @@ export function fn<
133132 return Object . assign ( call , shell ) as unknown as TgpuFnShell < Args , Return > ;
134133}
135134
136- export function isTgpuFn < Args extends AnyData [ ] | [ ] , Return extends AnyData > (
135+ export function isTgpuFn < Args extends BaseData [ ] | [ ] , Return extends BaseData > (
137136 value : unknown | TgpuFn < ( ...args : Args ) => Return > ,
138137) : value is TgpuFn < ( ...args : Args ) => Return > {
139138 return isMarkedInternal ( value ) &&
@@ -151,7 +150,7 @@ function stringifyPair([slot, value]: SlotValuePair): string {
151150function createFn < ImplSchema extends AnyFn > (
152151 shell : TgpuFnShellHeader <
153152 Parameters < ImplSchema > ,
154- Extract < ReturnType < ImplSchema > , AnyData >
153+ Extract < ReturnType < ImplSchema > , BaseData >
155154 > ,
156155 implementation : Implementation < ImplSchema > ,
157156) : TgpuFn < ImplSchema > {
@@ -217,7 +216,7 @@ function createFn<ImplSchema extends AnyFn>(
217216 }
218217
219218 const castAndCopiedArgs = args . map ( ( arg , index ) =>
220- schemaCallWrapper ( shell . argTypes [ index ] as unknown as AnyData , arg )
219+ schemaCallWrapper ( shell . argTypes [ index ] as unknown as BaseData , arg )
221220 ) as InferArgs < Parameters < ImplSchema > > ;
222221
223222 const result = implementation ( ...castAndCopiedArgs ) ;
0 commit comments