TS8035
프런트엔드 코드 CLASS_MEMBER
A class member shape the surface does not take, or a use of a member the class rules refuse, and a new that builds no class (Rule 8.13).
레지스트리 설명과 컴파일러 메시지는 컴파일러 원문이라 한국어 페이지에서도 영어로 둡니다.
발생 조건
A class member shape the surface does not take, or a use of a member the class rules refuse, and a new that builds no class (Rule 8.13). Getters and setters, static fields and methods, overload signatures, abstract members, # private names and methods that change their object all compile, and so does a field holding a function, which is a method (Rule 8.16). What is refused, in the declaration: a field holding a function when the field is static, or when the function takes type parameters, is async or a generator, or is an expression body with no return type; a static block, an index signature, a second constructor, a second body for a method, a decorator on a method or on a parameter property, an async or generator method, an abstract member with a body or an initializer, an abstract method or accessor in a class that is not abstract or in the class a mixin returns, an abstract overload signature of a method whose body is not, a class that is not abstract and leaves an abstract method or accessor unimplemented (an abstract field is a member of every struct below it), one name declared as two kinds of member, or as another kind than the class it extends declares it, two members that would emit one function or constant name (a private name loses its #), and a parameter named self_, the name the emitted function gives its object. A second body and an abstract member are said where they are written, whether or not the class is instantiated or the mixin applied. In a use: this outside a method, or naming an instance field in a static one; super.m with no body above to name, or naming a field holding a function; an instance method called on the class or a static one on a value; a member the class does not have; a # member reached outside its class body; a getter with no setter assigned, or a setter with no getter read; a compound assignment through a getter and setter whose object would run twice; a method that changes its object called on something it cannot write (a parameter, a const whose value something else may hold, a dropped value) or used as a value when it returns nothing. In a new, once for the file where the new is written, an abstract class, new this() outside a static member, and a target that resolves to something other than a class — a WGSL constructor or cast (new vec3f()), a type alias of one (type S = vec3), a WGSL type with no constructor (new sampler()) or one the library declares for TypeScript (new Array(4)), a function (Math.sin and an imported one included), an enum or one of its members, a namespace, Math, console or Symbol, an interface or type alias, a type parameter, a mixin applied to a class, or a value (PI included). A target nothing declares, and a member the object before it does not have (new Math.Foo()), is UNKNOWN_NAME. A getter or setter missing its type is UNKNOWN_TYPE, a readonly field written outside the constructor CONST_ASSIGN.
예제
"use typeshade"
class Ray { origin: vec3 static count: f32 = 0. static { Ray.count = 1. }}
@fragmentexport function main(@location(0) uv: 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(@location(0) uv: vec2): vec4 { return vec4(uv, 0., 1.)}이 코드가 적용하는 규칙
- 규칙 6.7 테스트
- The attribute names the compiler reads are
@vertex,@fragment,@compute,@builtin,@location,@interpolate,@invariant,@blend_src, and@diagnostic(the last four since #168, surface §53 and §54); every other WGSL attribute is either inferred by the compiler or carried as an argument (@compute([64, 1, 1])carries@workgroup_size), and a decorator outside that list must be refused. - 규칙 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 top-level function; an entry method on a class must be refused.
- 규칙 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 toref(...)(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 (Rule 8.10); 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.
함께 보기
-
TS8002UNKNOWN_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, animplementsclause, 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). -
TS8005CONST_ASSIGN const나 읽기 전용 리소스처럼 바뀔 수 없는 이름에 값을 대입합니다.-
TS8022UNKNOWN_NAME - Reference to a name TypeShade cannot resolve (identifier, struct field, or struct shape) that is not a function call (
UNKNOWN_FN) or a type name (UNKNOWN_TYPE), in a body a call lowers or in one no call lowers; a name the library declares for TypeScript's own use (Object,Math,Symbol), or the file declares as an enum, a namespace, a class or a type, read as a value says what it is.
소스
커밋 c66579bf에서 컴파일러가 이 코드를 내는 곳입니다. 파일마다 한 줄씩 적었습니다.
-
src/compiler/ts/lower/class-access.ts:53 -
src/compiler/ts/lower/class-methods.ts:248 -
src/compiler/ts/lower/expression-prop.ts:236(3곳) -
src/compiler/ts/lower/function.ts:2086(2곳) -
src/compiler/ts/lower/new-target.ts:141(3곳) -
src/compiler/ts/lower/statement.ts:1815(2곳) -
src/compiler/ts/semantic.ts:415 -
src/compiler/ts/structs.ts:1095 -
src/language-service/diagnostics.ts:2351(3곳)