TS8002
프런트엔드 코드 UNKNOWN_TYPE
A type name nothing declares, said once for the file wherever it is written (a parameter, a claim, a type argument, B<vec3<Foo>> included, an alias, an implements clause, the base a class or an interface extends, a body no call lowers), a type the library declares for TypeScript alone (Number) where the file declares none of its name, or a type this surface does not take in a position the mapper reads (Rule 2.1).
레지스트리 설명과 컴파일러 메시지는 컴파일러 원문이라 한국어 페이지에서도 영어로 둡니다.
발생 조건
A type name nothing declares, said once for the file wherever it is written (a parameter, a claim, a type argument, B<vec3<Foo>> included, an alias, an implements clause, the base a class or an interface extends, a body no call lowers), a type the library declares for TypeScript alone (Number) where the file declares none of its name, or a type this surface does not take in a position the mapper reads (Rule 2.1). A base the file declares and does not collect as a struct is the struct collector's, STRUCT_FIELD.
예제
"use typeshade"
function shade(x: float): f32 { return x * 0.5}
@fragmentexport function main(@location(0) uv: vec2): vec4 { return vec4(uv, shade(uv.x), 1.)}빌드할 때 고정된 컴파일러로 이 프로그램을 컴파일하면 다음 진단이 나옵니다.
TS8002 error, 3행: Unknown type "float". GLSL's and HLSL's float is f32 here.
고치는 법
같은 프로그램을 고친 모습입니다. 진단 없이 컴파일됩니다.
"use typeshade"
function shade(x: f32): f32 { return x * 0.5}
@fragmentexport function main(@location(0) uv: vec2): vec4 { return vec4(uv, shade(uv.x), 1.)}이 코드가 적용하는 규칙
- 규칙 2.1 테스트
- Every author-facing name must come from exactly one of three sources:
- 규칙 4.1 테스트
- Every type an author writes must be a WGSL type under a TypeScript spelling, or a member of the f64 family (Rule 4.4).
- 규칙 4.6 테스트
numberandbooleanmust not be written as shader types; a number on the GPU has a width, and the boolean is spelledbool.- 규칙 4.8 테스트
- Every
matCxRwithCandRin 2, 3, 4 must be a type, and a square one must also answer tomatN. - 규칙 6.2 테스트
- A storage binding’s access mode is its second type argument:
storage<T>isvar<storage, read>andstorage<T, "read_write">isvar<storage, read_write>. - 규칙 8.18 테스트
- A function whose parameter has a function type, written out (
f: (x: f32) => f32) or through a type alias of one, takes a function: a function declared at the top of the file or of a namespace, a method, a static method, a constructor, a field that holds a function (Rule 8.16) and a local function (Rule 8.17). - 규칙 8.19 테스트
- A function that writes no return type returns what its body does, as TypeScript infers it: a function of the file or of a namespace, a local function (Rule 8.17), each instance of a generic function (Rule 8.9) and of a function that takes a function (Rule 8.18), a method, a getter and a field that holds a function (Rule 8.16) take the type of their first
returnwith a value, thereturns after it are typed against that type as against a written one, and one with no suchreturnreturns nothing. - 규칙 12.4 테스트
- One mistake reads as one diagnostic; a refusal must not be followed by further diagnostics about the same mistake.
- 규칙 12.6 테스트
- A requirement the front end can check must be checked at the front end, in the author’s words, and not left to Tint or a driver.
함께 보기
-
TS8010STRUCT_FIELD - An invalid struct field or declaration shape.
소스
커밋 c66579bf에서 컴파일러가 이 코드를 내는 곳입니다. 파일마다 한 줄씩 적었습니다.
-
src/compiler/ts/bindings.ts:240(3곳) -
src/compiler/ts/generic-structs.ts:155 -
src/compiler/ts/generics.ts:147 -
src/compiler/ts/lower/expression-array.ts:92(4곳) -
src/compiler/ts/lower/expression-call.ts:544 -
src/compiler/ts/lower/function.ts:695(4곳) -
src/compiler/ts/lower/statement.ts:560 -
src/compiler/ts/module-const.ts:665 -
src/compiler/ts/semantic.ts:159(2곳) -
src/compiler/ts/source-file.ts:481 -
src/compiler/ts/type-map.ts:1326(5곳)