跳到主要内容
文档

错误码

v1.0.0-alpha.15 面共有 29 个 OEC 编译器诊断与 3 个运行时错误码。下表每一行都由触发它的源码渲染而成。

01 / 码表

错误码,以及它们被触发的位置。

OEC90xx 系列是编译器诊断:每个码对应一条编译元素边界强制执行的语法规则,每一行列出构建产生它的确切源码调用点。运行时错误码是应用可以分支处理的 ErrorCode 常量。码不可能只出现在源码里而不出现在这里。

OEC9000编译器语法

String(…)

2 条不同消息: String(…) · diagnosticMessage(…)

c/internal/compiler/semantic-core/compiler-diagnostics.ts:67 · c/internal/compiler/semantic-core/server-component.ts:301
OEC9001编译器语法

expected exactly one @element(...) class per compiled module (the decorator must bind the canonical element import from '@openelement/element')

c/internal/compiler/semantic-core/analyze-module.ts:907
OEC9002编译器语法

@element option "…" may appear only once

9 条不同消息: @element option "…" may appear only once · @element options must be an object literal · @element options must be named literal assignments · @element options support only root, delegatesFocus and formAssociated · @element requires a string tag name plus an optional options object · @element root "…" is unsupported; use "light", "shadow-open" or "shadow-closed" · @element root must be a string literal · @element tag "…" is not a custom-element name — use a lowercase name with at least one dash (my-element) · @element … must be a boolean literal

c/internal/compiler/semantic-core/analyze-module.ts:954 · c/internal/compiler/semantic-core/analyze-module.ts:962 · c/internal/compiler/semantic-core/analyze-module.ts:979 · c/internal/compiler/semantic-core/analyze-module.ts:984 · c/internal/compiler/semantic-core/analyze-module.ts:988 · c/internal/compiler/semantic-core/analyze-module.ts:993 · c/internal/compiler/semantic-core/analyze-module.ts:999 · c/internal/compiler/semantic-core/analyze-module.ts:1011 · c/internal/compiler/semantic-core/analyze-module.ts:1020
OEC9003编译器语法

compiled classes must be named

2 条不同消息: compiled classes must be named · compiled classes must extend a canonical import of OpenElement or ErrorBoundary from '@openelement/element' (found ……)

c/internal/compiler/semantic-core/analyze-module.ts:1058 · c/internal/compiler/semantic-core/analyze-module.ts:1067
OEC9004编译器语法

compiled OpenElement classes must carry exactly one @element decorator

6 条不同消息: compiled OpenElement classes must carry exactly one @element decorator · method parameters may not carry decorators in the compiler grammar · methods may not carry decorators in the compiler grammar · unknown decorator on an OpenElement class; use only @element · unknown decorator on an OpenElement member; use only @property · unknown decorator on an OpenElement member; use only @property imported from '@openelement/element'

c/internal/compiler/semantic-core/analyze-module.ts:479 · c/internal/compiler/semantic-core/analyze-module.ts:494 · c/internal/compiler/semantic-core/analyze-module.ts:675 · c/internal/compiler/semantic-core/analyze-module.ts:680 · c/internal/compiler/semantic-core/analyze-module.ts:917 · c/internal/compiler/semantic-core/analyze-module.ts:945
OEC9005编译器语法

@property reflect must be a boolean literal

10 条不同消息: @property reflect must be a boolean literal · @property requires one options object literal · compiled @property fields must be ordinary initialized instance fields · compiled classes may declare static styles only once · compiled fields must carry exactly one @property decorator · compiled fields require an admitted initializer — a serializable literal, computed(...), or trustedHtml(...) · duplicate property "…" · property name "…" is unsafe — prototype-pollution primitives are on the shared deny list; rename the property · property names must be identifiers · static styles requires an initializer

c/internal/compiler/semantic-core/analyze-module.ts:433 · c/internal/compiler/semantic-core/analyze-module.ts:436 · c/internal/compiler/semantic-core/analyze-module.ts:466 · c/internal/compiler/semantic-core/analyze-module.ts:472 · c/internal/compiler/semantic-core/analyze-module.ts:500 · c/internal/compiler/semantic-core/analyze-module.ts:508 · c/internal/compiler/semantic-core/analyze-module.ts:514 · c/internal/compiler/semantic-core/analyze-module.ts:520 · c/internal/compiler/semantic-core/analyze-module.ts:546 · c/internal/compiler/semantic-core/analyze-module.ts:569
OEC9006编译器语法

compiled @element classes must be exported (optionally as the default export) without other class modifiers

4 条不同消息: compiled @element classes must be exported (optionally as the default export) without other class modifiers · compiled methods must be concrete instance methods · constructors, accessors and undecorated fields are outside the compiler grammar — declare state as @property fields and behavior as methods · method names must be identifiers

c/internal/compiler/semantic-core/analyze-module.ts:672 · c/internal/compiler/semantic-core/analyze-module.ts:685 · c/internal/compiler/semantic-core/analyze-module.ts:705 · c/internal/compiler/semantic-core/analyze-module.ts:934
OEC9007编译器语法

a server function component must be a single return of one JSX element

8 条不同消息: a server function component must be a single return of one JSX element · a server function component must return one element · compiled classes may declare only one render() method · compiled classes must declare render() · render() must be a single return of one JSX element · render() must be a synchronous zero-argument method · render() must return a single JSX element · render() must return one intrinsic JSX element

c/internal/compiler/semantic-core/analyze-module.ts:689 · c/internal/compiler/semantic-core/analyze-module.ts:695 · c/internal/compiler/semantic-core/analyze-module.ts:710 · c/internal/compiler/semantic-core/compile.ts:146 · c/internal/compiler/semantic-core/compile.ts:151 · c/internal/compiler/semantic-core/lower-program.ts:464 · c/internal/compiler/semantic-core/server-component.ts:192 · c/internal/compiler/semantic-core/server-component.ts:439
OEC9008编译器语法

runtime top-level statements are outside the compiled module grammar — keep shared state in a plain module and import it; the island policy statement (export const openElement = defineIslandConfig(...)) is the one admitted runtime statement

c/internal/compiler/semantic-core/analyze-module.ts:874
OEC9010编译器语法

component tag <…> is outside the compiler grammar (intrinsic lowercase elements and custom-element hosts only) — custom elements compose by tag name — use the tag string, not the class value

4 条不同消息: component tag <…> is outside the compiler grammar (intrinsic lowercase elements and custom-element hosts only) — custom elements compose by tag name — use the tag string, not the class value · itemTagReason · list Block item must be an intrinsic lowercase element or a custom-element host — compose by tag name, not class values · tagReason

c/internal/compiler/semantic-core/lower-program.ts:501 · c/internal/compiler/semantic-core/lower-program.ts:506 · c/internal/compiler/semantic-core/lower-program.ts:1482 · c/internal/compiler/semantic-core/lower-program.ts:1488
OEC9011编译器语法

attribute name "…" is unsafe — names must be valid HTML attribute names, not event handlers (on*) or forbidden sinks; use an admitted attribute name

17 条不同消息: attribute "…" must be a literal or a supported expression · attribute "…" must be a literal, this.<property>, or a supported expression · attribute "…" only accepts primitive literal values — use a string, number or boolean literal (objects and arrays have no attribute form) · attribute name "innerHTML" is unsafe as a static attribute — innerHTML opens only through the trusted-HTML sink: bind an Object-typed trustedHtml(...) property and carry the literal trustedHtml marker · attribute name "…" is unsafe — names must be valid HTML attribute names, not event handlers (on*) or forbidden sinks; use an admitted attribute name · conditional class branches must be string literals: class={this.<cond> ? 'a' : 'b'} · conditional class conditions must read at least one ….<property> · duplicate attribute "…" is unsupported — remove one; an element admits each attribute once · item template attribute "…" must be a static literal or {….<field>} · item template attributes must use primitive literals — use a string, number or boolean literal, or bind {….<field>} · key is only supported on the list Block item root · list Block items do not support spread attributes — write each attribute explicitly (a literal or {<item>.<field>}) · property sink name "…" is unsafe — prototype-pollution primitives are on the shared deny list on every boundary; rename the attribute · property sink name "…" is unsafe — prototype-pollution primitives are on the shared deny list on every boundary; rename the sink · ref must reference this.<field> · spread attributes are not supported by the compiler grammar — write each attribute explicitly (a literal or a this.<property> sink) · spread attributes are not supported in item templates — write each attribute explicitly (a literal or {<item>.<field>})

c/internal/compiler/semantic-core/lower-program.ts:532 · c/internal/compiler/semantic-core/lower-program.ts:568 · c/internal/compiler/semantic-core/lower-program.ts:587 · c/internal/compiler/semantic-core/lower-program.ts:597 · c/internal/compiler/semantic-core/lower-program.ts:615 · c/internal/compiler/semantic-core/lower-program.ts:653 · c/internal/compiler/semantic-core/lower-program.ts:708 · c/internal/compiler/semantic-core/lower-program.ts:723 · c/internal/compiler/semantic-core/lower-program.ts:731 · c/internal/compiler/semantic-core/lower-program.ts:857 · c/internal/compiler/semantic-core/lower-program.ts:1062 · c/internal/compiler/semantic-core/lower-program.ts:1087 · c/internal/compiler/semantic-core/lower-program.ts:1174 · c/internal/compiler/semantic-core/lower-program.ts:1186 · c/internal/compiler/semantic-core/lower-program.ts:1197 · c/internal/compiler/semantic-core/lower-program.ts:1399 · c/internal/compiler/semantic-core/lower-program.ts:1497 · c/internal/compiler/semantic-core/lower-program.ts:1505 · c/internal/compiler/semantic-core/lower-program.ts:1521 · c/internal/compiler/semantic-core/lower-program.ts:1530 · c/internal/compiler/semantic-core/lower-program.ts:1548 · c/internal/compiler/semantic-core/lower-program.ts:1609 · c/internal/compiler/semantic-core/lower-program.ts:1617
OEC9012编译器语法

nested Blocks are outside the compiler grammar

9 条不同消息: a text-only ternary is not a Block — Blocks swap elements; derive the text in a computed(...) property and interpolate {this.<property>} · conditional Block branches must be single static JSX elements — each branch is exactly one element (bind its values as this.<property> attributes) · event handlers are only supported on list Block item templates · nested Blocks are outside the compiler grammar · nested ternaries are outside the compiler grammar — one condition per Block; derive the decision in a computed(...) property and branch on it · … — a branch cannot interpolate text; bind the value as an attribute (e.g. data-label={this.<property>}) · … — a ref cannot bind inside a branch · … — an event handler cannot bind inside a branch · … — an inline conditional class cannot bind inside a branch

c/internal/compiler/semantic-core/lower-program.ts:624 · c/internal/compiler/semantic-core/lower-program.ts:650 · c/internal/compiler/semantic-core/lower-program.ts:668 · c/internal/compiler/semantic-core/lower-program.ts:1240 · c/internal/compiler/semantic-core/lower-program.ts:1259 · c/internal/compiler/semantic-core/lower-program.ts:1273 · c/internal/compiler/semantic-core/lower-program.ts:1345 · c/internal/compiler/semantic-core/lower-program.ts:1353 · c/internal/compiler/semantic-core/lower-program.ts:1360 · c/internal/compiler/semantic-core/lower-program.ts:1578
OEC9013编译器语法

list Block mapper must return one JSX element

14 条不同消息: JSX fragments and spreads are outside the compiler grammar — wrap the fragment's children in a single element · conditional Blocks support this.<property> compared with a numeric literal (>, >=, <, <=), a number/string/boolean equality (===, !==), or a bare this.<property> (optionally negated) truthiness test · dynamic child literals must be primitive values · item child must be {….<field>} · item templates support static text, item values and intrinsic elements · list Block items must bind at least one {<item>.<field>} value or attribute slot · list Block mapper must be a single-parameter arrow function · list Block mapper must return one JSX element · list Blocks must map over this.<property> · list Blocks support exactly this.<property>.map(...) · sink … cannot anchor in server function output · unsupported condition … · unsupported dynamic expression; use this.<property>, a supported condition, or this.<array>.map(...) · void element <…> may not have children

c/internal/compiler/semantic-core/lower-program.ts:765 · c/internal/compiler/semantic-core/lower-program.ts:817 · c/internal/compiler/semantic-core/lower-program.ts:1252 · c/internal/compiler/semantic-core/lower-program.ts:1279 · c/internal/compiler/semantic-core/lower-program.ts:1313 · c/internal/compiler/semantic-core/lower-program.ts:1373 · c/internal/compiler/semantic-core/lower-program.ts:1376 · c/internal/compiler/semantic-core/lower-program.ts:1383 · c/internal/compiler/semantic-core/lower-program.ts:1386 · c/internal/compiler/semantic-core/lower-program.ts:1390 · c/internal/compiler/semantic-core/lower-program.ts:1439 · c/internal/compiler/semantic-core/lower-program.ts:1630 · c/internal/compiler/semantic-core/lower-program.ts:1659 · c/internal/compiler/semantic-core/lower-program.ts:1683 · c/internal/compiler/semantic-core/server-component.ts:659 · c/internal/compiler/semantic-core/server-component.ts:692
OEC9014编译器语法

key must be key={<item>.<field>}

4 条不同消息: key must be key={<item>.<field>} · key must reference ….<field> · list Block items may declare key only once · list Block items require key={<item>.<field>}

c/internal/compiler/semantic-core/lower-program.ts:1405 · c/internal/compiler/semantic-core/lower-program.ts:1411 · c/internal/compiler/semantic-core/lower-program.ts:1422 · c/internal/compiler/semantic-core/lower-program.ts:1425
OEC9015编译器语法

… part path […] is preceded by a dynamic anchor; path-addressed fixed sinks must appear before any dynamic anchor sibling

c/internal/compiler/semantic-core/emit-program.ts:57
OEC9016编译器语法

event arithmetic supports only numeric += or -= literals

6 条不同消息: event arithmetic supports only numeric += or -= literals · event arrow handlers must contain exactly one supported action · event assignment values must be serializable literals · event handlers must be this.<method> or a single-action arrow · event mutations support only this.<number>++ or -- · unsupported event action; use this.<field>++, assignment or this.<method>()

c/internal/compiler/semantic-core/lower-program.ts:946 · c/internal/compiler/semantic-core/lower-program.ts:958 · c/internal/compiler/semantic-core/lower-program.ts:989 · c/internal/compiler/semantic-core/lower-program.ts:1001 · c/internal/compiler/semantic-core/lower-program.ts:1018 · c/internal/compiler/semantic-core/lower-program.ts:1026
OEC9017编译器语法

custom-element host <…> may not carry event handlers — bind the handler on an intrinsic element, or attach the listener imperatively in a lifecycle method

3 条不同消息: custom-element host <…> may not carry a ref — query the host imperatively in a lifecycle method (e.g. connectedCallback) · custom-element host <…> may not carry event handlers — bind the handler on an intrinsic element, or attach the listener imperatively in a lifecycle method · custom-element host <…> may not have children in the compiler grammar (slots are unsupported)

c/internal/compiler/semantic-core/lower-program.ts:560 · c/internal/compiler/semantic-core/lower-program.ts:644 · c/internal/compiler/semantic-core/lower-program.ts:1570 · c/internal/compiler/semantic-core/lower-program.ts:1635
OEC9020编译器语法

property defaults must be serializable literals

c/internal/compiler/semantic-core/analyze-module.ts:542
OEC9021编译器语法

property type/converter must be one of String, Number, Boolean, Array or Object

c/internal/compiler/semantic-core/analyze-module.ts:167
OEC9022编译器语法

@property option "…" may appear only once

3 条不同消息: @property option "…" may appear only once · @property options must be named literal assignments · unsupported @property option "…" — admitted options are type, converter, reflect and attribute

c/internal/compiler/semantic-core/analyze-module.ts:557 · c/internal/compiler/semantic-core/analyze-module.ts:561 · c/internal/compiler/semantic-core/analyze-module.ts:600
OEC9023编译器语法

a property with attribute: false cannot reflect

4 条不同消息: a property with attribute: false cannot reflect · duplicate property attribute "…" · property attribute must be a string literal or false · property attribute name "…" is unsafe — use a valid HTML attribute name (no on* handlers, no forbidden sinks)

c/internal/compiler/semantic-core/analyze-module.ts:582 · c/internal/compiler/semantic-core/analyze-module.ts:588 · c/internal/compiler/semantic-core/analyze-module.ts:630 · c/internal/compiler/semantic-core/analyze-module.ts:635
OEC9024编译器语法

computed field arrows may not declare parameters

11 条不同消息: computed field arrows may not declare parameters · computed field arrows use an expression body, not a block · computed field arrows use an expression body, not a block (keep derived values atomic) · computed fields take exactly one zero-argument arrow function · event actions may not write computed field "…" — assign its source properties · … may not nest non-arrow functions — hoist the function to module scope and import it · … may not read computed field "…" — read its source this.<property> inputs instead (computed fields cannot chain) · … may not read computed field "…" — read its source ….<property> inputs instead (computed fields cannot chain) · … may only read this.<declared property> (found this.…) · … may only read ….<declared property> (found ….…) · … may only reference this.<property>

c/internal/compiler/semantic-core/analyze-module.ts:226 · c/internal/compiler/semantic-core/analyze-module.ts:241 · c/internal/compiler/semantic-core/analyze-module.ts:249 · c/internal/compiler/semantic-core/analyze-module.ts:263 · c/internal/compiler/semantic-core/analyze-module.ts:271 · c/internal/compiler/semantic-core/analyze-module.ts:280 · c/internal/compiler/semantic-core/analyze-module.ts:333 · c/internal/compiler/semantic-core/analyze-module.ts:337 · c/internal/compiler/semantic-core/analyze-module.ts:348 · c/internal/compiler/semantic-core/analyze-module.ts:352 · c/internal/compiler/semantic-core/lower-program.ts:977
OEC9025编译器语法

computed fields require @property({ reflect: false, attribute: false }) — derived signals have no attribute channel

2 条不同消息: computed fields require @property({ reflect: false, attribute: false }) — derived signals have no attribute channel · computed fields require the canonical computed import: a runtime named import of computed from '@openelement/element'…

c/internal/compiler/semantic-core/analyze-module.ts:324 · c/internal/compiler/semantic-core/analyze-module.ts:621
OEC9026编译器语法

an innerHTML sink target must be otherwise childless (the sink owns its content)

8 条不同消息: an innerHTML sink target must be otherwise childless (the sink owns its content) · innerHTML sinks require an Object-typed TrustedHtml property · innerHTML sinks require the explicit trustedHtml capability marker · trustedHtml capability marker must be the literal true · trustedHtml capability marker requires an innerHTML sink · trustedHtml field defaults require the canonical trustedHtml import: a runtime named import of trustedHtml from '@openelement/element'… · trustedHtml field defaults require type: Object, reflect: false, and attribute: false · void element <…> cannot carry an innerHTML sink — move the sink to a container element (e.g. <div>)

c/internal/compiler/semantic-core/analyze-module.ts:130 · c/internal/compiler/semantic-core/analyze-module.ts:612 · c/internal/compiler/semantic-core/lower-program.ts:525 · c/internal/compiler/semantic-core/lower-program.ts:747 · c/internal/compiler/semantic-core/lower-program.ts:756 · c/internal/compiler/semantic-core/lower-program.ts:1148 · c/internal/compiler/semantic-core/lower-program.ts:1155 · c/internal/compiler/semantic-core/lower-program.ts:1162
OEC9027编译器语法

unsupported @element provenance: …

2 条不同消息: unsupported @element provenance: … · unsupported @property provenance: …

c/internal/compiler/semantic-core/analyze-module.ts:488 · c/internal/compiler/semantic-core/analyze-module.ts:901
OEC9029编译器语法

duplicate sheet import binding "…" — a compiled module's .css imports bind distinct names so static styles can array them individually

3 条不同消息: duplicate sheet import binding "…" — a compiled module's .css imports bind distinct names so static styles can array them individually · the .css import "…" ("…") is never arrayed in static styles — every sheet import of a compiled module is adopted by its class · … — write the sheet to a .css file, import it (`import sheet from './<component>.css'`) and array the binding in static styles; inline sheet strings are retired (#1558)

c/internal/compiler/semantic-core/style-imports.ts:39 · c/internal/compiler/semantic-core/style-imports.ts:99 · c/internal/compiler/semantic-core/style-imports.ts:165
OEC9030编译器语法

island config root "…" is unsupported; use "light" or "shadow"

3 条不同消息: island config root "…" is unsupported; use "light" or "shadow" · island config root must be a string literal · the island config declares root "…" but @element('…', { root: '…' }) compiles a …-rooted program. The @element decorator owns the root — point the config at the light component (@element(tag, { root: 'light' })) or drop the config's root field so the two agree.

c/internal/compiler/semantic-core/analyze-module.ts:787 · c/internal/compiler/semantic-core/analyze-module.ts:793 · c/internal/compiler/semantic-core/analyze-module.ts:1035
OEC9031编译器语法

event handlers are a client-only construct — a server function component renders static HTML and may not carry …; interactivity belongs to an @element island (a compiled component), not to server markup

2 条不同消息: event handlers are a client-only construct — a server function component renders static HTML and may not carry …; interactivity belongs to an @element island (a compiled component), not to server markup · refs are a client-only construct — a server function component renders static HTML and may not carry a ref; element access belongs to an @element island (a compiled component), not to server markup

c/internal/compiler/semantic-core/lower-program.ts:551 · c/internal/compiler/semantic-core/lower-program.ts:635 · c/internal/compiler/semantic-core/lower-program.ts:869 · c/internal/compiler/semantic-core/lower-program.ts:1561
OEC9032编译器语法

the props parameter must be a plain identifier

18 条不同消息: "…" is reserved for the generated constructor imports (…) — remove or rename the module-scope binding · <…> is not a server function component — import it from the module that exports it (a server function component composes only by direct call to another server function component; @element components compose by tag name) · a server function component has no this — read the props parameter (props.<field>) instead; `this` belongs to the @element class path · a trustedHtml sink cannot cross a __ssr host — pass the trusted value as the component's own property instead · component prop "…" must be a literal or a props.<field> read · component prop "…" must be a literal or a props.<field> read — arbitrary expressions are outside the server function grammar · component prop names must be plain identifiers · server function component … may not be async — a component returns its HTML synchronously; async data belongs in the route loader · server function component … may not declare type parameters · server function component … must have a body · server function component … takes at most one props parameter · the props parameter must be a plain identifier · the props parameter must be annotated inline as an object type literal (props: { name: string }) — type aliases and interfaces are outside the server function grammar · the props type admits property signatures only · this exported function renders JSX but is not an admitted server function component (a component is a single return of one JSX element) — runtime JSX has no interpreter in the server lane; fix the shape or move it out of the module · … "…" is not a plain identifier — the generated module writes it into an identifier position, so the compiler refuses to emit it · … takes at most one props parameter · ….children is not declared — add `children?: string` to the props type: the JSX children a caller nests compose it as one final-HTML string

c/internal/compiler/semantic-core/lower-program.ts:845 · c/internal/compiler/semantic-core/lower-program.ts:863 · c/internal/compiler/semantic-core/lower-program.ts:887 · c/internal/compiler/semantic-core/lower-program.ts:901 · c/internal/compiler/semantic-core/lower-program.ts:1227 · c/internal/compiler/semantic-core/server-component.ts:135 · c/internal/compiler/semantic-core/server-component.ts:144 · c/internal/compiler/semantic-core/server-component.ts:173 · c/internal/compiler/semantic-core/server-component.ts:181 · c/internal/compiler/semantic-core/server-component.ts:186 · c/internal/compiler/semantic-core/server-component.ts:200 · c/internal/compiler/semantic-core/server-component.ts:208 · c/internal/compiler/semantic-core/server-component.ts:219 · c/internal/compiler/semantic-core/server-component.ts:225 · c/internal/compiler/semantic-core/server-component.ts:246 · c/internal/compiler/semantic-core/server-component.ts:352 · c/internal/compiler/semantic-core/server-component.ts:368 · c/internal/compiler/semantic-core/server-component.ts:605 · c/internal/compiler/semantic-core/server-component.ts:727
BOUNDARY_CAUGHT运行时

BOUNDARY_CAUGHT
SSR_RENDER_ERROR运行时

SSR_RENDER_ERROR
UNKNOWN运行时

UNKNOWN

摘要取该码触发次数最多的消息;调用点消息不唯一时会展开完整列表。源码路径均为仓库相对路径。

由 pnpm --dir www run check:error-codes 从诊断生成,因此新码无法不登记,退役的码也无法留在表上。