TS8004
On this page

TS8004

Front-end code UNKNOWN_FN

A call to a function the file neither declares nor imports.

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(@location(0) uv: 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(@location(0) uv: 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.

See also

Source

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

Edit this page Report a problem