Skip to content

Commit 9fbd3f0

Browse files
authored
Merge branch 'main' into chore/simplify-tsconfig
2 parents fef5348 + 4d64cf4 commit 9fbd3f0

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

packages/typegpu/src/core/constant/tgpuConstant.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ class TgpuConstImpl<TDataType extends AnyWgslData>
5555
'~resolve'(ctx: ResolutionCtx): string {
5656
const id = ctx.names.makeUnique(getName(this));
5757
const resolvedValue = ctx.resolveValue(this._value, this.dataType);
58+
const resolvedDataType = ctx.resolve(this.dataType);
5859

59-
ctx.addDeclaration(`const ${id} = ${resolvedValue};`);
60+
ctx.addDeclaration(`const ${id}: ${resolvedDataType} = ${resolvedValue};`);
6061

6162
return id;
6263
}

packages/typegpu/tests/constant.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe('tgpu.const', () => {
1515

1616
expect(parseResolved({ fn1 })).toBe(
1717
parse(`
18-
const x = 2;
18+
const x: u32 = 2;
1919
fn fn1() {
2020
return x;
2121
}
@@ -56,7 +56,7 @@ describe('tgpu.const', () => {
5656
vel: vec3u,
5757
}
5858
59-
const boid = Boid(vec3f(1, 2, 3), vec3u(4, 5, 6));
59+
const boid: Boid = Boid(vec3f(1, 2, 3), vec3u(4, 5, 6));
6060
6161
fn func() {
6262
var pos = boid;

0 commit comments

Comments
 (0)