chore: Add type checks to std - #2863
Open
aleksanderkatan wants to merge 74 commits into
Open
Conversation
Bundle size comparison (
|
| 🟢 Decreased | ➖ Unchanged | 🔴 Increased (max 3.19%) | ❔ Unknown |
|---|---|---|---|
| 0 | 191 | 134 | 0 |
import * as ... in PR vs import * as ... in target (did bundle size increase?):
Click to reveal the results table (134 entries).
| Test | tsdown |
|---|---|
| std_neg.ts | 39.38 kB ( |
| std_add.ts | 39.38 kB ( |
| std_bitShiftLeft.ts | 39.38 kB ( |
| std_bitShiftRight.ts | 39.38 kB ( |
| std_div.ts | 39.38 kB ( |
| std_mod.ts | 39.38 kB ( |
| std_mul.ts | 39.38 kB ( |
| std_sub.ts | 39.38 kB ( |
| std_rotateX4.ts | 40.21 kB ( |
| std_scale4.ts | 40.21 kB ( |
| std_translate4.ts | 40.21 kB ( |
| std_rotateY4.ts | 40.22 kB ( |
| std_rotateZ4.ts | 40.22 kB ( |
| std_dot.ts | 58.00 kB ( |
| std_length.ts | 58.00 kB ( |
| std_distance.ts | 58.00 kB ( |
| std_dot4U8Packed.ts | 58.00 kB ( |
| std_fract.ts | 58.00 kB ( |
| std_frexp.ts | 58.00 kB ( |
| std_mix.ts | 58.00 kB ( |
| std_modf.ts | 58.00 kB ( |
| std_abs.ts | 58.01 kB ( |
| std_acos.ts | 58.01 kB ( |
| std_acosh.ts | 58.01 kB ( |
| std_asin.ts | 58.01 kB ( |
| std_asinh.ts | 58.01 kB ( |
| std_atan.ts | 58.01 kB ( |
| std_atan2.ts | 58.01 kB ( |
| std_atanh.ts | 58.01 kB ( |
| std_ceil.ts | 58.01 kB ( |
| std_clamp.ts | 58.01 kB ( |
| std_cos.ts | 58.01 kB ( |
| std_cosh.ts | 58.01 kB ( |
| std_countLeadingZeros.ts | 58.01 kB ( |
| std_countOneBits.ts | 58.01 kB ( |
| std_countTrailingZeros.ts | 58.01 kB ( |
| std_cross.ts | 58.01 kB ( |
| std_degrees.ts | 58.01 kB ( |
| std_determinant.ts | 58.01 kB ( |
| std_dot4I8Packed.ts | 58.01 kB ( |
| std_exp.ts | 58.01 kB ( |
| std_exp2.ts | 58.01 kB ( |
| std_extractBits.ts | 58.01 kB ( |
| std_faceForward.ts | 58.01 kB ( |
| std_firstLeadingBit.ts | 58.01 kB ( |
| std_firstTrailingBit.ts | 58.01 kB ( |
| std_floor.ts | 58.01 kB ( |
| std_fma.ts | 58.01 kB ( |
| std_insertBits.ts | 58.01 kB ( |
| std_intdiv.ts | 58.01 kB ( |
| std_inverseSqrt.ts | 58.01 kB ( |
| std_ldexp.ts | 58.01 kB ( |
| std_log.ts | 58.01 kB ( |
| std_log2.ts | 58.01 kB ( |
| std_max.ts | 58.01 kB ( |
| std_min.ts | 58.01 kB ( |
| std_normalize.ts | 58.01 kB ( |
| std_pow.ts | 58.01 kB ( |
| std_quantizeToF16.ts | 58.01 kB ( |
| std_radians.ts | 58.01 kB ( |
| std_reflect.ts | 58.01 kB ( |
| std_refract.ts | 58.01 kB ( |
| std_reverseBits.ts | 58.01 kB ( |
| std_round.ts | 58.01 kB ( |
| std_saturate.ts | 58.01 kB ( |
| std_sign.ts | 58.01 kB ( |
| std_sin.ts | 58.01 kB ( |
| std_sinh.ts | 58.01 kB ( |
| std_smoothstep.ts | 58.01 kB ( |
| std_sqrt.ts | 58.01 kB ( |
| std_step.ts | 58.01 kB ( |
| std_tan.ts | 58.01 kB ( |
| std_tanh.ts | 58.01 kB ( |
| std_transpose.ts | 58.01 kB ( |
| std_trunc.ts | 58.01 kB ( |
| d_vec2b.ts | 42.04 kB ( |
| d_mat4x4f.ts | 42.03 kB ( |
| d_vec2u.ts | 42.03 kB ( |
| d_vec3b.ts | 42.03 kB ( |
| d_vec3f.ts | 42.03 kB ( |
| d_vec3u.ts | 42.03 kB ( |
| d_vec4b.ts | 42.03 kB ( |
| d_vec4u.ts | 42.03 kB ( |
| d_mat2x2f.ts | 42.04 kB ( |
| d_mat3x3f.ts | 42.04 kB ( |
| d_vec2f.ts | 42.04 kB ( |
| d_vec2h.ts | 42.04 kB ( |
| d_vec3h.ts | 42.04 kB ( |
| d_vec4h.ts | 42.04 kB ( |
| d_vec2i.ts | 42.04 kB ( |
| d_vec3i.ts | 42.04 kB ( |
| d_vec4f.ts | 42.04 kB ( |
| d_vec4i.ts | 42.04 kB ( |
| std_bitcastF32toU32.ts | 36.93 kB ( |
| std_bitcastU32toF32.ts | 36.94 kB ( |
| std_bitcastU32toI32.ts | 36.94 kB ( |
| std_bitcast.ts | 36.94 kB ( |
| std_and.ts | 38.59 kB ( |
| std_or.ts | 38.59 kB ( |
| std_all.ts | 38.59 kB ( |
| std_allEq.ts | 38.60 kB ( |
| std_any.ts | 38.60 kB ( |
| std_eq.ts | 38.60 kB ( |
| std_lt.ts | 38.60 kB ( |
| std_ne.ts | 38.60 kB ( |
| std_not.ts | 38.60 kB ( |
| std_select.ts | 38.60 kB ( |
| std_ge.ts | 38.60 kB ( |
| std_gt.ts | 38.60 kB ( |
| std_isCloseTo.ts | 38.60 kB ( |
| std_le.ts | 38.60 kB ( |
| STATIC_std.ts | 99.30 kB ( |
| STATIC_d.ts | 79.00 kB ( |
| STATIC_tgpu.ts | 274.43 kB ( |
| tgpu_fn.ts | 274.43 kB ( |
| tgpu_init.ts | 274.44 kB ( |
| tgpu_lazy.ts | 274.44 kB ( |
| tgpu_slot.ts | 274.44 kB ( |
| tgpu_const.ts | 274.44 kB ( |
| tgpu_unroll.ts | 274.44 kB ( |
| tgpu_resolve.ts | 274.44 kB ( |
| tgpu_accessor.ts | 274.44 kB ( |
| tgpu_comptime.ts | 274.44 kB ( |
| tgpu_vertexFn.ts | 274.44 kB ( |
| tgpu_computeFn.ts | 274.44 kB ( |
| tgpu_fragmentFn.ts | 274.44 kB ( |
| tgpu_privateVar.ts | 274.44 kB ( |
| tgpu_vertexLayout.ts | 274.44 kB ( |
| tgpu_workgroupVar.ts | 274.44 kB ( |
| tgpu_initFromDevice.ts | 274.45 kB ( |
| tgpu_bindGroupLayout.ts | 274.45 kB ( |
| tgpu_mutableAccessor.ts | 274.45 kB ( |
| tgpu_resolveWithContext.ts | 274.45 kB ( |
| STATIC_allImports.ts | 300.69 kB ( |
import { ... } in PR vs import * as ... in PR (is the library tree-Shakeable?):
| Test | tsdown |
|---|---|
| tgpu_init.ts | 264.91 kB ( |
| tgpu_initFromDevice.ts | 264.36 kB ( |
| tgpu_resolve.ts | 163.51 kB ( |
| tgpu_resolveWithContext.ts | 163.44 kB ( |
| tgpu_bindGroupLayout.ts | 63.54 kB ( |
| tgpu_mutableAccessor.ts | 58.26 kB ( |
| tgpu_accessor.ts | 58.26 kB ( |
| tgpu_privateVar.ts | 56.95 kB ( |
| tgpu_workgroupVar.ts | 56.95 kB ( |
| tgpu_const.ts | 56.37 kB ( |
| tgpu_lazy.ts | 56.17 kB ( |
| tgpu_fragmentFn.ts | 39.68 kB ( |
| tgpu_fn.ts | 39.62 kB ( |
| tgpu_vertexFn.ts | 39.50 kB ( |
| tgpu_computeFn.ts | 39.20 kB ( |
| tgpu_vertexLayout.ts | 28.33 kB ( |
| tgpu_comptime.ts | 15.93 kB ( |
| tgpu_unroll.ts | 1.75 kB ( |
| tgpu_slot.ts | 1.70 kB ( |
If you wish to run a comparison for other, slower bundlers, run the 'Tree-shake test' from the GitHub Actions menu.
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.96, 1.95, 4.37, 7.27, 8.55, 11.39, 25.55, 24.39]
line [1.05, 2.00, 4.46, 6.44, 7.85, 13.22, 24.95, 26.65]
line [1.02, 2.03, 4.34, 6.85, 8.44, 12.84, 24.44, 23.34]
---
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.32, 0.49, 0.73, 0.87, 1.18, 1.31, 1.51, 1.55]
line [0.29, 0.48, 0.68, 0.81, 1.10, 1.18, 1.40, 1.60]
line [0.29, 0.51, 0.70, 0.87, 1.23, 1.29, 1.47, 1.72]
---
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.93, 2.73, 5.29, 8.69, 14.11, 27.87, 59.55, 121.41]
line [1.00, 2.37, 4.16, 7.30, 12.81, 27.19, 58.22, 118.25]
line [0.87, 2.15, 3.82, 7.49, 12.90, 27.27, 58.19, 118.91]
|
aleksanderkatan
marked this pull request as ready for review
August 19, 2026 14:23
aleksanderkatan
force-pushed
the
impr/clean-up-vectorops
branch
from
August 19, 2026 14:26
5e5d55f to
1fd63f3
Compare
aleksanderkatan
marked this pull request as draft
August 19, 2026 14:32
aleksanderkatan
marked this pull request as ready for review
August 25, 2026 13:13
aleksanderkatan
requested review from
cieplypolar,
iwoplaza,
reczkok and
vende11s
August 26, 2026 10:17
cieplypolar
approved these changes
Aug 26, 2026
cieplypolar
left a comment
Collaborator
There was a problem hiding this comment.
Very cool. Left one nit.
| ]); | ||
| export const floatKind: Set<Kind> = new Set([...f32Kind, ...f16Kind]); | ||
| export const signedKind: Set<Kind> = new Set([...i32Kind, ...f32Kind, ...f16Kind]); | ||
| export const numericKind: Set<Kind> = new Set([...i32Kind, ...u32Kind, ...f32Kind, ...f16Kind]); |
Collaborator
There was a problem hiding this comment.
Suggested change
| export const numericKind: Set<Kind> = new Set([...i32Kind, ...u32Kind, ...f32Kind, ...f16Kind]); | |
| export const numericKind: Set<Kind> = new Set([...signedKind, ...u32Kind]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2828
These are a runtime overhead, if this turns out to be detrimental, we can add an if to each check that returns early, or put all checks in ifs.
This definitely does not have full coverage, there still are functions with missing implementation/generalization/type checks, but I treat this PR as a step in the right direction, not an absolute std solution.