TS8004
On this page

TS8004

Front-end code UNKNOWN_FN

A call to a function the file neither declares nor imports, or to a builtin the language removed because ECMAScript spells it, such as arrayLength(xs), whose message names xs.length (Rule 9.9).

The registry has no documentation comment for this constant, so the line above is written by this site from the messages the compiler raises it with.

The registry text and every compiler message on these pages are the compiler's own English.

Example

example.shade.ts
"use typeshade"
@fragment
export function main(uv: location<0, vec2>): vec4 {
return vec4(uv, brightness(uv), 1.)
}

Compiled at build time against the pinned compiler, this program gets:

TS8004 error, line 5: Unknown function "brightness". Declare it in this file, or import it from another shader module.

How to fix it

The same program, corrected. It compiles with no diagnostic.

example.shade.ts
"use typeshade"
import { brightness } from "./brightness.shade.ts"
@fragment
export function main(uv: location<0, vec2>): vec4 {
return vec4(uv, brightness(uv), 1.)
}

It imports from another file of the same program, which compile() reads through its readDocument option:

brightness.shade.ts
"use typeshade"
export function brightness(uv: vec2): f32 {
return (uv.x + uv.y) * 0.5
}

The rules this enforces

Rule 2.1 Test
Every author-facing name must come from exactly one of three sources:
Rule 2.2 Test
A compiler-internal name (§2.1) must not be authorable.
Rule 7.7 Test
discard must be written as a bare statement, the identifier alone (discard), and may stand in a fragment entry and in a helper no vertex or compute entry can reach.
Rule 9.9 Test
A WGSL built-in function, an overload of one, or a §9.3 name must not be authorable when an ECMAScript spelling the compiler supports carries every case it accepts with the same meaning (Rule 1.4).

See also

Source

Where the compiler raises this code at commit af54ddad5, one line per file:

Edit this page Report a problem