규칙 4.1
이 페이지에서

규칙 4.1

4장, 타입 테스트

Every type an author writes must be a type borrowed from WGSL under a TypeScript spelling, a member of the f64 family (Rule 4.4), a key type, or a type ECMAScript defines that the compiler represents (Rule 1.5). A union of string literal types, or one string literal type, is a key type (change 0081): a u32 under that spelling, whose members are its values, each held as its id, the member’s index in the order of the members’ UTF-16 code units. A key type takes ===, !== and switch over its members, and no other operator; a value of another key type, or a number, is no value of it. Record<K, V> with K a key type is an array<V, N>, N the number of members, indexed by the member’s id (change 0081): r[k] with k of the key type, r.g and r["g"] the constant index of "g", and an object literal with one value for each member, in any order, its value.

Record<K, V> also takes an enum or a union of integer literals when its distinct values are exactly 0 through N-1, indexed by the member value; other numeric domains are refused with their actual values (change 0081, decision 2).

규칙 본문과 그 아래 항목은 설계 문서에 적힌 컴파일러 원문이라 한국어 페이지에서도 영어로 둡니다.

근거

the layout, the constructors, and the builtins of a type borrowed from WGSL are WGSL’s, and a type WGSL does not have has none of those; a type ECMAScript defines keeps ECMAScript’s meaning and takes the representation the compiler chooses (Rule 1.5), as Map and Set do (change 0080).

출처

changes/0100-typescript-meaning.md (section 2); Types, Plain Types and Texture and Sampler Types.

검증 방식

테스트로 확인합니다. 테스트나 게이트 스크립트, CI 워크플로가 이 규칙을 가리키고, 아래 파일 가운데 하나라도 규칙을 더는 가리키지 않으면 추적 검사가 실패합니다.

컴파일러가 이 규칙을 적용하는 곳을 규칙이 직접 적은 내용입니다.

SUPPORTED_TYPE_NAMES in src/compiler/ts/type-map.ts (TS8002 UNKNOWN_TYPE names the whole list) and surface-names.test.ts for the spellings; keyTypeT in src/compiler/ts/key-types.ts and src/compiler/ts/key-types.test.ts for the key types, in the compiler and in the language service.

커밋 af54ddad5에서 이 규칙을 확인하는 파일입니다. 파일마다 규칙을 처음 가리키는 줄로 연결했습니다.

설명하는 절

커밋 af54ddad5의 언어 문서에서 이 규칙을 설명하는 절입니다.

적용하는 오류 코드

규칙이 Enforced by 항목에서 가리키는 진단 코드와, 레지스트리 설명에서 이 규칙을 가리키는 진단 코드입니다.

TS8002 UNKNOWN_TYPE
아무것도 선언하지 않은 타입 이름입니다. 매개변수, 타입 인자, 별칭, implements 절, 기반 클래스 어디에 써도 걸리고, 이 표면이 매퍼가 읽는 자리에서 받지 않는 타입도 여기에 속합니다(규칙 2.1). 파일이 선언했지만 구조체로 모으지 않은 기반은 STRUCT_FIELD입니다.

함께 보기

소스

커밋 af54ddad5의 규칙 원문:

이 페이지 편집 문제 보고