Commit graph

2044 commits

Author SHA1 Message Date
Kristiyan Kostadinov
0950524ed7 refactor(compiler): allow directives to be resolved on host element (#62965)
Allows the target binder to resolve directives set on the host element.

PR Close #62965
2025-08-05 10:04:25 +02:00
Joey Perrott
cbc258eec8 build: remove ts_project_interop infrastructure (#62908)
Remove the interop macros and final usages

PR Close #62908
2025-07-31 09:12:58 +00:00
Matthieu Riegler
5b25d93f27 fix(compiler): exclude more safe reads expression from 2way-binding (#62852)
Priori to this fix the parser would allow safereads in accestor receievers (but the direct one).

fixes #62837

PR Close #62852
2025-07-29 17:28:08 +00:00
Joey Perrott
17ada9838b build: move tsec to new toolchain (#62825)
Migrate tsec tooling/macro to use tsec directly as a js_binary and rely on ts_project dependencies.

PR Close #62825
2025-07-28 20:07:05 +02:00
Matthieu Riegler
7aacd569f5 refactor(compiler): Error on comment only interpolations (#62590)
This commit introduces a ParserError to prevent an error later in the pipepine

fixes #34084

PR Close #62590
2025-07-24 09:19:46 +00:00
Kristiyan Kostadinov
7767aa640c fix(compiler): allow more characters in square-bracketed attribute names (#62742)
Currently the HTML parser will stop parsing as soon as it hits an end character in the name of an attribute (e.g. `/` or `>`). This ends up being problematic with some third-party packages like Tailwind which uses a wider range of characters for its class names. While the characters are fine when inside the `class` attribute, our current parser behavior prevents users from setting those classes conditionally through `[class.]` bindings.

These changes adjust the parser to handle such cases.

Fixes #61671.

PR Close #62742
2025-07-23 11:06:47 -04:00
Jessica Janiuk
882522c1ad refactor(compiler): Tree shake Element Registry (#62682)
This creates a feature to detect usages of animate.leave and only enables the element removal registry when necessary

PR Close #62682
2025-07-23 09:37:16 -04:00
Leon Senft
4138aca91f feat(core): render ARIA property bindings as attributes (#62630)
Allow binding to ARIA attributes using property binding syntax _without_
the `attr.` prefix. For example, `[aria-label]="expr"` is now valid, and
equivalent to `[ariaLabel]="expr"`. Both examples bind to either a
matching input or the `aria-label` HTML attribute, rather than the
`ariaLabel` DOM property.

Binding ARIA properties as attributes will ensure they are rendered
correctly on the server, where the emulated DOM may not correctly
reflect ARIA properties as attributes.

Reuse the DOM schema registry from the compiler to map property names in
type check blocks.

PR Close #62630
2025-07-22 06:59:00 -04:00
Joey Perrott
8bf97d1370 build: remove all usages of the interop_deps attr for ts_project and ng_project (#62732)
Remove all of the usages of interop_deps as attributes in the repo

PR Close #62732
2025-07-21 13:03:09 -04:00
Matthieu Riegler
3171d01452 fix(compiler): fix detection of directive deps in JIT (#62666)
This fix also matches the implementation to the jsdoc for `hasDirectiveDependencies` "Whether any of the component's dependencies are directives"

fixes #62573

PR Close #62666
2025-07-17 14:20:31 -04:00
Jessica Janiuk
fc8247de95 refactor(core): add compiler support for animation instructions (#62528)
this adds the compiler code to support the animate instructions.

PR Close #62528
2025-07-16 16:44:16 -04:00
Kristiyan Kostadinov
6dc29b3bf7 refactor(core): expose function to assert type of variables (#62648)
Adds the `ɵassertType` function that will be used during type checking to assert the type of a value.

PR Close #62648
2025-07-16 12:40:25 +02:00
Kristiyan Kostadinov
acdb8d673d refactor(compiler): indicate whether element is void at AST level (#62648)
Updates the HTML AST to indicate whether a specific element is a void element.

PR Close #62648
2025-07-16 12:40:25 +02:00
Kristiyan Kostadinov
18a675081f fix(compiler): more permissive parsing of @ characters (#62644)
When we introduced blocks, we made a deliberate decision to treat the `@` character as a reserved character in case we need to use it for other syntax in the future. This meant that some common cases, like writing out an email address in the template, can be broken.

After some recent discussions we decided to relax the requirement and only treat `@` as a reserve character if it's followed by a character sequence that matches a known block.

PR Close #62644
2025-07-15 13:24:47 -07:00
Kristiyan Kostadinov
56fbb3299a test(compiler): remove duplicated lexer tests (#62644)
There were 26 duplicated block tests in `lexer_spec.ts`, likely due to merge conflicts. These changes remove the duplicates while keeping the 6 tests that were different.

PR Close #62644
2025-07-15 13:24:47 -07:00
Kristiyan Kostadinov
a1e3f2bcd1 fix(compiler): incorrect spans for left side of binary operation (#62641)
Fixes that the span for the `left` side of a `Binary` AST included the range up to and including the operator.

Fixes #62617.

PR Close #62641
2025-07-15 07:57:32 -07:00
Joey Perrott
415833f2ce build: migrate angular-optimization from devinfra to devtools (#62503)
Migrate angular-optimization to devtools instead of loading via npm package

PR Close #62503
2025-07-07 17:05:51 +00:00
Paul Gschwendtner
633d01b571 refactor(compiler): ensure compiler passes closure conformance checks (#62500)
This commit adjusts some code of the compiler that currently results in
conformance checks failures with JSCompiler/Closure.

PR Close #62500
2025-07-07 16:14:16 +00:00
Paul Gschwendtner
c575286812 refactor: fix closure compatibility errors in compiler (#62493)
The static fields may be part of advanced compilations where the
receiver would change as part of the static field collapsing
optimization.

The optimization requires us to use the explicit class name, over
`this` that would change to e.g. `globalThis`.

PR Close #62493
2025-07-07 12:59:25 +02:00
Kristiyan Kostadinov
8fbe558cbc perf(core): move property remapping for dom properties to compiler (#62421)
Since we know that DOM properties won't go to an inputs, we can move the remapping logic to the compiler, saving us some processing on the client.

PR Close #62421
2025-07-02 14:28:12 +00:00
Jessica Janiuk
d7b94e0072 refactor(core): rename all animations package symbols (#62399)
Renames all animations package references with a "legacy" prefix for later easy cleanup.

PR Close #62399
2025-07-01 13:45:45 +00:00
Joey Perrott
b84859073b build: migrate to use web test runner rules (#62292)
Migrate karma tests throughout the repo to use the new web test runner based rule instead

PR Close #62292
2025-06-26 17:19:10 +00:00
Kristiyan Kostadinov
089ad0ee15 fix(compiler): produce more accurate errors for interpolations (#62258)
Currently when there's a parser error in interpolated text, the compiler reports an error on the entire text node. This can be really noisy in long strings.

These changes switch to reporting the errors on the specific expressions that caused them.

PR Close #62258
2025-06-25 16:58:56 +00:00
Kristiyan Kostadinov
d1cb44d60a refactor(compiler): remove I18nError (#62160)
Removes the `I18nError` class since it wasn't being used for anything aside from a wrapper.

PR Close #62160
2025-06-23 14:25:28 +02:00
Kristiyan Kostadinov
982f90ff35 refactor(compiler): remove TokenError (#62160)
Replaces the `TokenError` class with `ParseError` to reduce the number of error classes we need to maintain.

PR Close #62160
2025-06-23 14:25:28 +02:00
Kristiyan Kostadinov
bcde744e0a refactor(compiler): remove _ControlFlowError (#62160)
Removes the `_ControlFlowError`, because its name is confusing and it's just a wrapper around `TokenError`.

PR Close #62160
2025-06-23 14:25:28 +02:00
Kristiyan Kostadinov
5e9707dc84 refactor(compiler): consolidate error classes (#62160)
Currently we have a `ParserError` that is used for the expression parser and a `ParseError` that is used everywhere else. These changes consolidate them into the `ParseError` to avoid confusion and make it easier to add more context in the future.

PR Close #62160
2025-06-23 14:25:28 +02:00
Kristiyan Kostadinov
6b5e6b7ff7 refactor(compiler): always generate DOM-only templates for blocks (#62096)
Block templates can't have directives so we can always generate them as DOM-only.

PR Close #62096
2025-06-23 14:24:09 +02:00
Kristiyan Kostadinov
2b4b98ded6 refactor(compiler): produce DOM-only instructions (#62096)
Reworks the compiler so that it produces DOM-only instructions and updates the relevant tests.

PR Close #62096
2025-06-23 14:24:09 +02:00
Kristiyan Kostadinov
3afd3046d7 refactor(compiler): track whether component has directive dependencies (#62096)
Adds a field to the directive's metadata tracking whether it has directive dependencies. Knowing this will allow the pipeline to decide whether to produce DOM-only or full instructions.

PR Close #62096
2025-06-23 14:24:09 +02:00
Kristiyan Kostadinov
8e5b70f80b refactor(core): expose DOM-only instructions to the compiler (#62096)
Makes it possible for the compiler to reference DOM-only instructions.

PR Close #62096
2025-06-23 14:24:09 +02:00
Kristiyan Kostadinov
0dcf230d52 feat(compiler): add support for new binary assignment operators (#62064)
Updates the remainder of the compiler to handle the new assignment operators and sets up more tests, including for the runtime.

PR Close #62064
2025-06-23 14:23:29 +02:00
Kristiyan Kostadinov
998b00e62f refactor(compiler): implement new binary operators in output AST (#62064)
Updates the output AST to support the new set of binary operators.

PR Close #62064
2025-06-23 14:23:29 +02:00
Kristiyan Kostadinov
0213cd23ff refactor(compiler): support new assignment operators in expression parser (#62064)
Updates the expression parser to account for the new assignment operators that were added to the lexer.

PR Close #62064
2025-06-23 14:23:29 +02:00
Kristiyan Kostadinov
cf3b583b43 refactor(compiler): support more assignment operators in lexer (#62064)
Adds support for the `+=`, `-=`, `*=`, `/=`, `%=`, `**=`, `&&=`, `||=` and `??=` assignment operators to the lexer.

PR Close #62064
2025-06-23 14:23:28 +02:00
Joey Perrott
3a0cfd544d build: migrate to using new jasmine_test (#62086)
Use the new jasmine_test based on rules_js instead of jasmine_node_test from rules_nodejs

PR Close #62086
2025-06-18 08:27:26 +02:00
Paul Gschwendtner
d081ef9b06 build: replace all ng_package with new rule from rules_angular (#61843)
Replaces all `ng_package` rule with the new rule from `rules_angular`.

PR Close #61843
2025-06-04 09:13:41 +00:00
Kristiyan Kostadinov
b1f3d2eab8 refactor(compiler): replace output AST write nodes (#61682)
Similarly to the previous change to the expression AST, these changes replace the `WriteVarExpr`, `WriteKeyExpr` and `WritePropExpr` from the output AST with a binary expression. This is closer aligned to TypeScript and makes it easier to translate code between the two.

PR Close #61682
2025-06-03 11:08:50 -04:00
Kristiyan Kostadinov
eb43e9242d refactor(compiler): account for new assignment AST (#61682)
Reworks the places that were depending on `PropertyWrite` and `KeyedWrite` to account for the new AST structure.

PR Close #61682
2025-06-03 11:08:50 -04:00
Kristiyan Kostadinov
08ee693995 refactor(compiler): produce binary expressions instead of dedicated write ones (#61682)
Currently our expression parser produces two different expressions for writes: `PropertyWrite` (e.g. `foo.bar = 123`) or `KeyedWrite` (e.g. `foo[0] = 123`). This is inconsistent with other ASTs, like TypeScript's, where writes are represented as binary expressions with a `=` operator and it makes it difficult to implement more write operators like `??=`, because we'd essentially have to duplicate them.

These changes switch the expression parser over to produce binary expressions instead.

PR Close #61682
2025-06-03 11:08:50 -04:00
Paul Gschwendtner
b7c5645f05 build: migrate packages/compiler-cli to ts_project (#61826)
This commit migrates the remaining pieces of `compiler-cli` to
`ts_project`. This involves a few more things during migration:

- the `ng_module` ngc_wrapped rule broke as part of this change, so we
  switched it to `ts_project` too. This logic is soon gone anyway.

- we needed an extra pnpm "package.json" for the linker babel test. This test is
  loading from the real compiler-cli npm package. Babel needs a real
  node module for this, so this solution seems reasonable. It may be
  worth exploring in the future to move this test into an integration
  test though.

- the older integrationtest in compiler-cli is removed as the coverage
  is much better with the compliance test suite and this test.

PR Close #61826
2025-06-03 11:41:52 +02:00
Kristiyan Kostadinov
fd5a04927e fix(compiler): recover invalid parenthesized expressions (#61815)
When the expression parser consumes tokens inside a parenthesized expression, it looks for valid tokens until it hits and invalid one or a closing paren. If it finds an invalid token, it reports and error and tries to recover until it finds a closing paren. The problem is that in such cases, it would produce the `ParenthesizedExpression` and continue parsing **from** from the closing paren which would then produce more errors that add noise to the output and result in an incorrect representation of the user's code. E.g. `foo((event.target as HTMLElement).value)` would be recovered to `foo((event.target)).value` instead of `foo((event.target).value)`.

These changes resolve the issue by skipping over the closing paren at the recovery point.

Fixes #61792.

PR Close #61815
2025-06-02 15:50:46 -04:00
Kristiyan Kostadinov
5a76826d26 fix(compiler): only report parser errors on invalid expression (#61793)
Currently we reuse the same binding parser for all expressions in the template. Under the hood, the parser has a single `errors` array that it passes into all ASTs which means that if there's one binding with an error, those errors will be propagated to all other ASTs in the template.

These changes switch to having a unique `errors` array for each AST so we only report errors once.

Relates to #61792.

PR Close #61793
2025-06-02 09:56:00 -04:00
Kristiyan Kostadinov
a70f03a9b4 fix(compiler): move defer trigger assertions out of parser (#61747)
When defer blocks have a reference-based trigger without a parameter, we infer it from the placeholder block. This requires some validations like ensuring that there's only one element in the placeholder. The validations are currently implemented at the parser level which can affect tools like linters that need to pass `preserveWhitespaces: true` in order to get accurate source mappings.

These changes move the validations into the template type checker so that they still get flagged, but much later in the process. Moving them over involves a bit more work, because the template type checker also sets `preserveWhitespaces: true`.

Fixes #61725.

PR Close #61747
2025-05-30 13:44:58 -04:00
Paul Gschwendtner
b80957d1c5 build: adjust bundling tests to use Angular CLI (#61566)
Instead of dev-infra maintaining a custom ESBuild + Terser pipeline that
tries to emulate the Angular CLI, we are switching the bundling core
tests to a new rule that really leverages the Angular CLI.

This involves some file renames and small adjustments. In addition, we
leverage the updated symbol tracking rule to output new goldens that can
work with multiple bundle files (as generated by the Angular CLI;
especially with defer and its "lazy" chunks).

PR Close #61566
2025-05-29 14:39:11 -04:00
Paul Gschwendtner
7bc39a883d build: fix app_bundle rule after migrating packages/compiler (#61566)
The `app_bundle` rule does not work after the migration of
`packages/compiler` to `ts_project` because the `.mjs` extensions are
now missing in the non npm-package output.

This causes runtime errors as `.js` is not recognized as ESM. Switching
to the real npm package for usage, fixes this issue.

PR Close #61566
2025-05-29 14:39:11 -04:00
Paul Gschwendtner
ef44f671f4 build: migrate packages/compiler to ts_project (#61566)
Migrates `packages/compiler` to `ts_project`.

PR Close #61566
2025-05-29 14:39:10 -04:00
Kristiyan Kostadinov
c11527fc68 refactor(compiler): remove unused code (#61668)
Removes the following unused code from the compiler:
* The ICU expander appears to be some really old code converting ICUs into legacy-style control flow directives. It's annoying to keep this one since we need to update it any time the AST changes.
* The `PipeCollector` class wasn't used anywhere.
* The `partitionArray` function wasn't used anywhere.
* The `newArray` function was used only in one test and it can be easily replaced with `new Array().fill`.

PR Close #61668
2025-05-26 12:21:09 +00:00
Matthieu Riegler
3e102f0b84 fix(compiler): lexer support for template literals in object literals (#61601)
This commit fixes a shortcoming of the lexer with template literals

fixes #61572

PR Close #61601
2025-05-26 10:24:16 +00:00
Kristiyan Kostadinov
289ae50c56 refactor(core): replace propertyInterpolateX with property (#61639)
Replaces the `propertyInterpolateX` instructions with calls to `property` and the `interpolate` helper. This allows us to drop the dedicated interpolation instructions and simplify the runtime for future work.

PR Close #61639
2025-05-26 09:21:23 +00:00