Repository navigation
Open
Description
The error conditions and tests of the attribute resolver reference in angular#67519, which has the rest. The implementation is angular#71966.
Error conditions
| Code | When | Effect |
|---|---|---|
NG0320 |
A handler calls resolve() twice, or after it returns or throws. |
Throws in dev mode. Production ignores a late call and keeps the call that starts last. |
NG0320 |
A shorthand callback returns a value that its own resolver didn't create. | Throws in dev mode. Production reads the value as a value. |
NG0320 |
A handler passes resolve() a result of another event, or passes a result as an extra. |
Throws in dev mode. Production reads a result of the same grammar as its value and any other as none. |
NG0320 |
A handler passes a function to resolve() or as an extra. |
Throws in dev mode. Production reads it as its source text for a scalar or token list, else as none. |
NG0321 |
A resolver binding, in a template or in host, is on <ng-container> or <ng-template>. |
Logged with console.error in dev mode. The binding does nothing. |
NG0322 |
A provider below the root turns automatic resolution on, and the root providers don't. | Throws in dev mode. Production ignores the feature in that provider. |
NG0323 |
A directive declares a resolver of an attribute and inherits another one. | Throws in dev mode. Production runs both, the base class's first. |
NG0324 |
Two directives give different values for a resolved scalar. | Logged with console.warn in dev mode, once per element and attribute. |
NG0600 |
A handler writes a signal. | Throws. |
NG0100 |
A handler writes a plain field that the element's bindings read. | Reported in an Eager view, or with exhaustive checkNoChanges. |
| None | provideAttributeResolvers() has a key for an event handler attribute. |
Throws in dev mode. |
NG5001 |
@HostListener('class'), @HostListener('style'), or @HostListener('attr.x'). |
Compile error. |
NG5001 |
Two resolvers of one attribute in one host, a chain in a host shorthand, or a host (attr.x) that can't be resolved. |
Compile error. |
NG5002 |
Two resolvers of one attribute on one template element, a chain in a template shorthand, or an (attr.x) that can't be resolved. |
Compile error. |
NG8120 |
A template resolver binding sits next to a directive output of the same name. | Compile-time warning by default. |
NG8121 |
A template resolver binding is on <ng-container>. |
Compile error. |
NG8122 |
A property binding writes an attribute that a resolver on the same element resolves. | Compile-time warning by default. |
TS2322, TS1360 |
A shorthand callback isn't a callback of its resolver, or returns something other than ResolvedAttribute. |
Compile error. |
TS2345 |
An extra or a resolve() argument doesn't fit the attribute's value type, or $event doesn't fit the handler's parameter. |
Compile error. |
TS2349 |
A shorthand calls its function instead of passing it. | Compile error. |
TS2554 |
A shorthand callback takes no parameter. | Compile error. |
TS2684 |
A shorthand calls a method that declares this without its receiver. |
Compile error. |
With strictOutputEventTypes: false, type checking reports only the errors of the call itself and
of the ordinary expressions, such as TS2684. JIT compilation and the linker throw the NG5001 and NG5002 errors with the same
messages, without the code.
Tests
pnpm bazel test //packages/core/test/acceptance/attribute_resolver:attribute_resolver //packages/core/test/acceptance/attribute_resolver:attribute_resolver_web //packages/core/test/acceptance/attribute_resolver:auto_resolution //packages/core/test/acceptance/attribute_resolver:auto_resolution_webpnpm bazel test //packages/platform-server/test:test //packages/platform-server/test:attribute_resolver_auto_hydration_testpnpm bazel test --local_test_jobs=1 //packages/compiler-cli/test/ngtsc:ngtscpnpm bazel test //packages/compiler-cli/src/ngtsc/typecheck/extended/test/checks/output_shadowed_by_attribute_resolver:test //packages/compiler-cli/src/ngtsc/typecheck/extended/test/checks/property_binding_bypasses_resolver:test //packages/compiler-cli/src/ngtsc/typecheck/extended/test/checks/uninvoked_function_in_event_binding:testpnpm bazel test --test_arg=--filter=r3_view_compiler_attribute_resolver //packages/compiler-cli/test/compliance/full:full //packages/compiler-cli/test/compliance/linked:linked //packages/compiler-cli/test/compliance/declaration-only:declaration-only //packages/compiler-cli/test/compliance/codegen:codegenThe code lives on feat/attribute-resolver:
- Runtime:
packages/core/src/render3/instructions/attribute_resolver.ts,
packages/core/src/render3/attribute_resolver_auto.ts, and the specs in
packages/core/test/acceptance/attribute_resolver/. - Public types and providers:
packages/core/src/render3/interfaces/attribute_resolver.tsand
packages/core/src/render3/attribute_resolver_provider.ts. - Hydration: the
*resolver*hydration*specs inpackages/platform-server/test/. - Compiler:
packages/compiler/src/render3/r3_attribute_resolver.ts, the shorthand expansion in
packages/compiler/src/template/pipeline/src/ingest.ts, type checking in
packages/compiler/src/typecheck/ops/events.ts, the extended checks under
packages/compiler-cli/src/ngtsc/typecheck/extended/checks/, and the compliance cases in
packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_attribute_resolver/.
Metadata
Metadata
Assignees
Labels
No labels
Activity