TS8035
프런트엔드 코드 CLASS_MEMBER
표면이 받지 않는 클래스 멤버 모양, 클래스 규칙이 거부하는 멤버 사용, 클래스를 만들지 않는 new입니다(규칙 8.13). getter와 setter, static 필드와 메서드, 오버로드 시그니처, abstract 멤버, # 비공개 이름, 객체를 바꾸는 메서드는 모두 컴파일됩니다. 메시지가 멤버나 대상과 고칠 방법을 알려 줍니다.
레지스트리에는 이 상수에 대한 문서 주석이 없습니다. 그래서 위 설명은 컴파일러가 이 코드와 함께 내는 메시지를 보고 이 사이트가 쓴 것입니다.
레지스트리 설명과 컴파일러 메시지는 컴파일러 원문이라 한국어 페이지에서도 영어로 둡니다.
예제
"use typeshade"
class Ray { origin: vec3 static count: f32 = 0. static { Ray.count = 1. }}
@fragmentexport function main(uv: location<0, vec2>): vec4 { return vec4(uv, 0., 1.)}빌드할 때 고정된 컴파일러로 이 프로그램을 컴파일하면 다음 진단이 나옵니다.
TS8035 error, 6행: A static block runs when the class is defined, and a shader has no such moment. Give each static field its value where it is declared.
고치는 법
같은 프로그램을 고친 모습입니다. 진단 없이 컴파일됩니다.
"use typeshade"
class Ray { origin: vec3 static count: f32 = 1.}
@fragmentexport function main(uv: location<0, vec2>): vec4 { return vec4(uv, 0., 1.)}이 코드가 적용하는 규칙
- 규칙 6.7 테스트
- The attribute names the compiler reads are
vertex,fragment,compute,workgroup_size,builtin,location,interpolate,invariantandblend_src(the last three since #168, surface §53). - 규칙 6.10 테스트
- A local
constbinds its name once and leaves what it holds as writable as TypeScript does. - 규칙 8.1 테스트
- An entry point is a function declaration at the top of the file or of a namespace, exported or not, with exactly one stage attribute written before the declaration:
@vertex export function vs(…),@fragment …, or@compute([x, y?, z?]) …. - 규칙 8.9 테스트
- Method dispatch must be static, and a generic function or class must be compiled once per set of type arguments the program uses (Rule 3.9).
- 규칙 8.10 테스트
- A method that writes its object (assigns to
thisor to a field, a component or an element of it, applies++or--to one, hands one to a parameter that its function writes (Rule 8.25), or calls such a method or reads such a getter onthis, on a field, a component or an element of it whatever class that field is, or throughsuper) must take the object by reference, and may return a value like any other method; a base’s body that a class calls throughsuperand that writes its object takes it by reference too, and so does the copy of a method that takes a function (Rule 8.18) when a function handed over writes the variable the call is on. - 규칙 8.11 테스트
- A
getorsetaccessor is a function of the module,Owner_get_xorOwner_set_x, which takes its object as a method does (Rules 8.10 and 8.28); a read ofo.xmust call the getter, and an assignment, a compound assignment,++and--must call the setter with the new value, the compound forms reading the old one through the getter. - 규칙 8.12 테스트
- A private name
#xmust be emitted without its#: a field as the struct memberx, a method asOwner_x, an accessor asOwner_get_xandOwner_set_x, a static field asOwner_x. - 규칙 8.13 테스트
- A static field must be a module constant
Owner_xwhen nothing in the program writes it, and a module variable in the per-invocation space (Rule 6.5) when something does; areadonlystatic is never written. - 규칙 8.15 테스트
- A member declared
privatemay be named only inside the body of the class that declares it, and one declaredprotectedonly inside the bodies of that class and of the classes that extend it, on an object of the naming body’s own class or of one that extends it; a name either rule does not allow must be refused with the remedy. - 규칙 8.16 테스트
- An instance field that holds an arrow function or a function expression is a method of its class under the field’s name: the function’s parameters, return type and body are the method’s, an expression body is the value it returns, and
thisin it is the object, as it is in TypeScript.
함께 보기
소스
커밋 af54ddad5에서 컴파일러가 이 코드를 내는 곳입니다. 파일마다 한 줄씩 적었습니다.
-
src/compiler/ts/builtin-check.ts:448 -
src/compiler/ts/lower/class-access/checks.ts:28 -
src/compiler/ts/lower/class-methods/push-diag.ts:11 -
src/compiler/ts/lower/expression-prop.ts:172(3곳) -
src/compiler/ts/lower/function-signature/parameters.ts:133 -
src/compiler/ts/lower/function.ts:2486 -
src/compiler/ts/lower/new-target.ts:71(3곳) -
src/compiler/ts/lower/statement/writable.ts:59(2곳) -
src/compiler/ts/semantic.ts:293 -
src/compiler/ts/structs/diagnostics.ts:7 -
src/language-service/diagnostics/refusal-tables.ts:11(2곳) -
src/language-service/diagnostics/refused-attributes.ts:64