Rule 4.2
Chapter 4, Types Test
A type alias is another name for its target.
An alias of a scalar, a vector, an array, or a struct must resolve wherever a type may stand, and an alias, an interface, or a class over an object type is one struct.
A builtin type name must win over an alias of the same name, so type vec3 = f32 does not make vec3 a scalar.
The rule text and the parts under it are the compiler's own English, as the design document writes them.
Rationale
the first two clauses are what a type alias means in TypeScript and in WGSL alike. The third is a recorded divergence from WGSL, where a module-scope declaration hides the predeclared object of the same name. It is kept because a file that re-types a builtin name would make every later use of that name mean something no reader of the surface can see.
Derives from
Type Aliases for the resolution; surface §2 (roadmap 0.3 item T2) for the precedence, which reverses Declaration and Scope (“predeclared objects, and objects declared at module-scope, are in scope across the entire program source”, and the example “Shadowing predeclared objects”, where a module-scope fn min() hides the builtin).
How it is verified
Checked by a test. A test, a gate script or a CI workflow names this rule, and the traceability check fails when a file listed below stops naming it.
Where the rule says the compiler enforces it:
src/compiler/ts/type-alias.test.ts (resolution, and “an alias cannot shadow a builtin name”) and TS8023 DUPLICATE_SYMBOL for a second declaration of one struct name, whether or not anything uses the struct (#172), pinned by src/compiler/ts/type-structs.test.ts.
The files that verify it at commit 26de7be8, each at the first line that names the rule:
Explained in
The sections of the surface document that explain this rule, at commit 26de7be8:
Error codes that enforce it
The diagnostic codes the rule names under Enforced by, or whose registry text names the rule:
-
TS8023DUPLICATE_SYMBOL - The same function, binding, module constant or struct name declared twice in one scope.
See also
- Rule 4.1 Test
- Rule 4.3 Test
- Design rules
- Error codes
Source
The rule at commit 26de7be8:
docs/language-design.md:273(the design document)reqs/rules/RULE-0402.md(its traceability item)