Commit graph

5374 commits

Author SHA1 Message Date
Paul Gschwendtner
bd2b454faf refactor(migrations): gracefully proceed if reference cannot be resolved (#61426)
A runtime error can surface when TypeScript internally fails to resolve
a reference that is named similar to an input, but no `.d.ts` is
available for it.

See example error:
https://github.com/microsoft/TypeScript/issues/61473#issuecomment-2746537781.

PR Close #61426
2025-05-19 11:04:54 +00:00
Pawel Kozlowski
c856f43b5f refactor(core): move the data store operation out of instructions (#61425)
The view data store operation is not an instruction and shouldn't be
located in the instructions folder.

PR Close #61425
2025-05-19 08:24:47 +00:00
Pawel Kozlowski
1a3351c4f5 refactor(core): move i18n logic into its dedicated package (#61425)
Move the i18n-related logic out of the instructions folder into
the i18n-dedicated folder / package.

PR Close #61425
2025-05-19 08:24:47 +00:00
Paul Gschwendtner
185b7801ee build: migrate packages/core/schematics to ts_project (#61420)
Migrates `packages/core/schematics` to `ts_project`. As part of this,
this commit cleans up some of the mixed module types and tsconfigs in
the folder. A single tsconfig (and it's test variant) are now used.

For the shipped schematics, we explicitly use the `.cjs` extension, so
that the bundles are properly recognized as CommonJS; even if they are
part of the `type: module` `@angular/core` package.

The `package.json` with `type: commonjs` is removed from
`packages/core/schematics` as it's no longer needed given the explicit
extension & caused issues as schematics are compiled with ESM but are
only later bundled for shipping & some tests as ESM.

PR Close #61420
2025-05-16 15:53:27 +00:00
Paul Gschwendtner
e056fa13df build: migrate more targets of @angular/core to ts_project (#61420)
Migrates more targets of `@angular/core` to `ts_project`. Remaining are:

 - tests
 - schematics

PR Close #61420
2025-05-16 15:53:27 +00:00
Andrew Scott
94f5a4b4d6 fix(core): Testing should not throw when Zone does not patch test FW APIs (#61376)
This prevents `core/testing` from throwing an error if ZoneJS is present
but does not patch the test FW APIs such that `fakeAsync` works
automatically. For example, there is currently no patching of the vitest
APIs, so if you try to use Vitest with Zone on the page, it will throw.

PR Close #61376
2025-05-16 07:53:41 +00:00
arturovt
eb53bda470 fix(core): enable stashing only when withEventReplay() is invoked (#61352)
Patch version of https://github.com/angular/angular/pull/61077.

PR Close #61352
2025-05-15 10:10:04 -07:00
Paul Gschwendtner
f2d6e59857 refactor: explicitly ensure ngDevMode types are available (#61365)
This commit adds an import to the `ng_dev_mode.ts` file that augments
`global` to have types for `ngDevMode`.

Notably this change is currently not needed because the file is loaded
by `ts_library` through `tsconfig#files`— but in a separate PR we are
switching the target to `ts_project` which no longer loads all Bazel
dependency files via `tsconfig#files`; resulting in the ambient types no
longer magically being available.

PR Close #61365
2025-05-15 12:45:13 +00:00
Paul Gschwendtner
f3f0769ce7 refactor: update packages/core:{core,src} to ts_project (#61336)
Updates `packages/core:core` and `packages/core/src/...` to `ts_project`
of `rules_js`.

PR Close #61336
2025-05-14 08:31:33 -07:00
Miles Malerba
42f203e029 docs: rename @nodoc to @docs-private (#61196)
This aligns with how angular/components marks their hidden APIs.
`@nodoc` has been broken since the switch to adev, this change should
properly hide the APIs again.

PR Close #61196
2025-05-13 17:15:37 -07:00
Paul Gschwendtner
899cb4ab49 refactor: add explicit types for exports relying on inferred call return type (#61316)
As part of the Bazel toolchain migration we noticed that implicit types
generated by the TypeScript compiler sometimes end up referencing types
from other packages (i.e. cross-package imports).

These imports currently work just because the Bazel `ts_library` and
`ng_module` rules automatically inserted a `<amd-module
name="@angular/x" />` into `.d.ts` of packages. This helped TS figure
out how to import a given file. Notably this is custom logic that is not
occuring in vanilla TS or Angular compilations—so we will drop this
magic as part of the toolchain cleanup!

To improve code quality and keep the existing behavior working, we are
doing the following:

- adding a lint rule that reduces the risk of such imports breaking. The
  failure scenario without the rule is that API goldens show unexpected
  diffs, and types might be duplicated in a different package!

- keeping the `<amd-module` headers, but we manually insert them into
  the package entry-points. This should ensure we don't regress
  anywhere; while we also improved general safety around this above.

Long-term, isolated declarations or a lint rule from eslint-typescript
can make this even more robust.

PR Close #61316
2025-05-13 22:46:00 +00:00
Kristiyan Kostadinov
7be6e5dc50 refactor(migrations): remove unused code (#61260)
The `waitForAsync` rule has been disabled internally which allows us to delete its code, as well as some unused adjacent code.

PR Close #61260
2025-05-12 15:34:08 -07:00
Paul Gschwendtner
0e3d4546b9 build: migrate compiler-cli/src/ngtsc to ts_project (#61237)
Migrates all of `compiler-cli/src/ngtsc` to `ts_project`. This change
was generated using Gemini.

PR Close #61237
2025-05-09 16:01:49 +00:00
Paul Gschwendtner
1bfd7bbd1c build: prepare for compiler-cli to be using ts_project (#61237)
Prepare the compiler-cli package for being ready for migration
to `ts_project`.

PR Close #61237
2025-05-09 16:01:49 +00:00
Paul Gschwendtner
1312eb1600 build: remove irrelevant madge circular deps tests (#61209)
We don't need this tooling anymore because we are already validating
that there are no circular dependencies via the `ng-dev` tooling that
checks `.ts` files directly.

Also these tests never actually failed to my knowledge.

PR Close #61209
2025-05-08 09:23:47 -07:00
Kristiyan Kostadinov
4623b61448 fix(core): missing useExisting providers throwing for optional calls (#61152)
Fixes that the runtime was throwing a DI error when attempting to inject a missing `useExisting` provider, despite the call being optional.

The problem was that when the provider has `useExisting`, we do a second `inject` call under the hood which didn't include the inject flags from the original call.

Fixes #61121.

PR Close #61152
2025-05-06 14:06:24 -07:00
Foysol Ahmed
968546976d docs: ViewContainerRef.createComponent jsdoc update (#61097)
Co-authored-by: Jessica Janiuk <1596273+thePunderWoman@users.noreply.github.com>
PR Close #61097
2025-05-02 07:57:11 -07:00
KryptonBD
8c6e101a61 docs: ViewContainerRef.createComponent jsdoc update to reflect actual behavior (#61097)
Fixes #59918

PR Close #61097
2025-05-02 07:57:11 -07:00
arturovt
075145ef93 refactor(core): tree-shake PROPAGATION_STOPPED_SYMBOL (#61004)
Adds `__PURE__` annotations to `PROPAGATION_STOPPED_SYMBOL` to enable tree-shaking, even if is is not referenced. This variable is not dropped when Angular is imported from a module that has `sideEffects` set to `true`.

PR Close #61004
2025-04-30 12:38:45 -07:00
Alan Agius
400dbc5b89 fix(core): properly handle app stabilization with defer blocks (#61056)
Previously, the app was marked as stable prematurely. For more details, see https://github.com/angular/angular/issues/61038#issuecomment-2837917180

Closes: #61038
(cherry picked from commit de649c9cfd)

PR Close #61056
2025-04-30 12:02:03 -07:00
arturovt
2e140a136a fix(core): prevent stash listener conflicts [patch] (#61063)
Patch version of https://github.com/angular/angular/pull/59635.

PR Close #61063
2025-04-30 09:23:19 -07:00
arturovt
dbb87026ca fix(core): call DestroyRef on destroy callback if view is destroyed [patch] (#61061)
Patch version of 5f7f04634f

PR Close #61061
2025-04-30 08:52:25 -07:00
cexbrayat
59050900a0 refactor(core): remove unused APP_EFFECT_SCHEDULER in effect code (#59679)
The `APP_EFFECT_SCHEDULER` Injection token is never used and not a public API.

PR Close #59679
2025-04-30 08:49:56 -07:00
Matthieu Riegler
a554208651 build: Run browsers tests without platform-browser-dynamic (#60937) (#61060)
Use the regular `platform-browser` providers instead.

PR Close #61060
2025-04-30 08:21:03 -07:00
vladboisa
0ee1a6e593 docs: add link label & paragraph for correct display (#60708)
PR Close #60708
2025-04-30 08:18:08 -07:00
vladboisa
770587a755 docs: add Security-DomSanitizer link in ElemnetRef&Renderer2 (#60708)
Renderer2 and ElementRef didn't mention the Security-DomSanitizer method, this will add clarity for potential user what to expect. Also swap deprecated "callout" class to docs-alert

Fixes #51208 , #46904

PR Close #60708
2025-04-30 08:18:08 -07:00
Jessica Janiuk
6b76bca0f7 Revert "build: Run browsers tests without platform-browser-dynamic (#60937)" (#61059)
This reverts commit b896ca8ed5.

PR Close #61059
2025-04-30 12:21:02 +02:00
arturovt
946b844e0d fix(core): async EventEmitter error should not prevent stability (#61028)
This commit wraps the `fn` invocation with `try-finally`, ensuring that the pending task (added in [this commit](d5c6ee432f)) is always removed.

Prior to this commit, if a subscriber threw an error, it would prevent the application from becoming stable — though this shouldn't happen under normal scenarios because the error should be handled by the RxJS error handler or Angular's error handler.

Errors should not silently prevent the application from being rendered on the server.

PR Close #61028
2025-04-29 22:14:16 -07:00
Matthieu Riegler
b2b8566e05 build: Run browsers tests without platform-browser-dynamic (#60937)
Use the regular `platform-browser` providers instead.

PR Close #60937
2025-04-29 12:10:54 -07:00
Andrew Scott
9c4591ce30 refactor(core): Update FakeNavigation to extract some Angular quirks (#60961)
This change updates the implementation of `FakeNavigation` to extract
some changes that were made due to quirks in Angular testing.

PR Close #60961
2025-04-28 14:36:25 -07:00
arturovt
81f655679e refactor(core): tree-shake NOT_SET and EMPTY_CLEANUP_SET (#60979)
Adds `__PURE__` annotations to `NOT_SET` and `EMPTY_CLEANUP_SET` to enable tree-shaking, even if they are not referenced. These variables are not dropped when Angular is imported from a module that has `sideEffects` set to `true`.

PR Close #60979
2025-04-25 08:42:13 -07:00
Jeevan Mahesha
3824519a27 docs: replace EventEmitter with output and self-closing tags in templates (#60910)
Replaced all instances of EventEmitter with the new output() utility.
Updated templates to use self-closing tags for cleaner markup.

PR Close #60910
2025-04-22 21:42:19 +02:00
Matthieu Riegler
adac95c7f9 refactor(core): mark makeEnvironmentProviders as public. (#60956)
`makeEnvironmentProviders` was already exported but didn't have the `@publicApi` tag.

PR Close #60956
2025-04-22 16:27:24 +02:00
Gabriel Bergoc
ea4a211216 fix(forms): make NgForm emit FormSubmittedEvent and FormResetEvent (#60887)
Currently, only forms created with `FormGroupDirective` emit events on
form submission and resetting. This commit extends this behavior to
Template-driven forms also.

Related to #58894

PR Close #60887
2025-04-22 13:04:41 +02:00
Matthieu Riegler
5555e9f7dc docs: update docs centered on NgModules (#60933)
PR Close #60933
2025-04-22 11:08:56 +02:00
Andrew Scott
5cd80525e7 refactor(core): Update Transition finished promise to not throw unhandled rejection (#60816)
As with `InternalNavigationResult`, this commit adds the `catch` to the
`finished` promise on `InternalNavigationTransition` to avoid unhandled
promise rejections.

PR Close #60816
2025-04-15 18:40:43 -04:00
JoostK
79ff75fcc3 test(core): type tests for linkedSignal (#60857)
This commit adds type inference tests for `linkedSignal` usages, to capture their behavior w.r.t.
type inference. Note that there's some situations where type inference doesn't work as you might
expect/hope; these have been included to capture their behavior but may be revisited in the future
if the inference capabilities are expanded for this scenario.

Closes #60423

PR Close #60857
2025-04-14 09:30:37 -04:00
Ryan Russell
b144126612 fix(core): inject migration: replace param with this. (#60713)
The inject tool inserts `const foo = this.foo` if code
in the constructor referenced the constructor parameter `foo`.
If `foo` is a readonly property, we can instead replace `foo` with
`this.foo`. This allows more properties to be moved out of the
constructor with combineMemberInitializers.
For now, it only touches initializers, not all of the code in the
constructor.

PR Close #60713
2025-04-10 13:31:31 -04:00
Matthieu Riegler
880ebf4a71 Revert "refactor(core): use stream in rxResource instead of loader (#59910)" (#60803)
This reverts commit 98a584c1e8.

PR Close #60803
2025-04-09 09:33:27 -07:00
JoostK
9241615ad0 fix(core): reduce total memory usage of various migration schematics (#60776)
This commit changes Tsurge's operation within angular-devkit (i.e. the CLI) to
no longer retain all programs across all migrations. This isn't necessary for
so-called "funnel" migrations so not retaining the programs for those migrations
is a pure performance win. The "complex" migrations may see increased execution time
given that the program is now being recreated for the actual migration phase to run,
although reduced memory pressure may help alleviate this overhead. Since this new
approach should help prevent Node from running out of memory and failing entirely
this is preferred over a potentially increased execution time.

Fixes #59813

PR Close #60776
2025-04-08 16:12:57 -07:00
Kristiyan Kostadinov
a382066165 refactor(migrations): simplify integration of tsurge migrations into the CLI (#60386) (#60776)
Currently when we reuse a Tsurge migration is reused externally, there's some glue code that needs to be executed in a specific order. The code gets copied between the different migrations which is error-prone and means that bugs may have to be fixed several times.

These changes move the common steps out into a separate function so that only the migration-specific logic (mostly instantiation and logging) is left in the schematic.

PR Close #60386

PR Close #60776
2025-04-08 16:12:56 -07:00
aparziale
f2bfa3151e fix(core): fix ng generate @angular/core:output-migration. Fixes angular#58650 (#60763)
Fixes #58650 - Insert a TODO comment for empty emit (without parameter).

PR Close #60763
2025-04-08 16:10:04 -07:00
cexbrayat
56db79a973 refactor(core): use stream in rxResource instead of loader (#59910)
With the changes in #59573, `resource` can now define a `stream` rather than a `loader`.
In the same PR, `rxResource` was updated to leverage this new functionality to handle multiple responses from the underlying observable,
rather than just the first one as it was previously.
This commit renames the `loader` option of `rxResource` into `stream` to be better aligned with its new behavior.

The previous version is temporarily kept and marked as deprecated to help migrating the current usage.

Before
```
usersResource = rxResource({
  request: () => ...,
  loader: ({ request }) => ...
});
```

After
```
usersResource = rxResource({
  request: () => ...,
  stream: ({ request }) => ...
});
```

PR Close #59910
2025-04-08 10:19:15 -07:00
Kristiyan Kostadinov
4c09fae588 refactor(platform-browser): remove GenericBrowserDomAdapter (#60760)
The `GenericBrowserDomAdapter` wasn't don't anything so we can drop it and have the `BrowserDomAdapter` extend `DomAdapter` directly.

PR Close #60760
2025-04-08 10:14:55 -07:00
Kristiyan Kostadinov
3441f7b914 fix(compiler): error if rawText isn't estimated correctly (#60529) (#60753)
The `TemplateLiteralElementExpr` has some logic where it tries to estimate the `rawText` if one isn't provided by looking at the node's source span. The problem with this approach is that we have some long-standing issues with our expression AST parser (see https://github.com/angular/angular/pull/60267#discussion_r1986402524) where it might not produce accurate spans if escape sequences are involved. This in turn can lead to unrecoverable errors, because TypeScript will throw an error if the raw string doesn't match the cooked one when constructing a TypeScript AST node.

These changes remove the logic that depends on the source span and relies purely on the secondary fallback that inserts escaped characters manually.

It's also worth noting that the `rawText` doesn't seem to matter much at this point, because the main usage of it is when downlevelling template literals to ES5 which we no longer support.

Fixes #60528.

PR Close #60529

PR Close #60753
2025-04-07 13:15:02 -07:00
Jamie Couperwhite
ae2fc18855 docs: fix typo in documentation for pendingUntilEvent (#60756)
PR Close #60756
2025-04-07 10:29:36 -07:00
Andrew Scott
1b36f6e1e0 refactor(common): Add hashchange event for traversals (#60682)
This commit adds the logic to emit the `hashchange` event for
traversals.

PR Close #60682
2025-04-03 16:54:57 -07:00
Andrew Scott
8880ed67f1 refactor(common): Update FakeNavigation deferred commit to use precommitHandler (#60652)
This commit updates the FakeNavigation implementation to match the
spec's new `precommitHandler` which replaces the old `commit: 'after-transition'`.

PR Close #60652
2025-04-03 16:53:07 -07:00
Doug Parker
12320347cc refactor(core): add ApplicationRef.prototype.bootstrapImpl with an injector parameter (#60622)
This is a roll forward of commit d5a8a1c524. Nothing is meaningfully different, as we're trying again to see if the CI failure is reproducible.

PR Close #60622
2025-04-03 10:48:02 -07:00
aparziale
006ac7f22f fix(core): fixes #592882 ng generate @angular/core:signal-queries-migration (#60688)
fixes #592882 - retain accessibility modifier if it's already present for signal migrations

PR Close #60688
2025-04-02 15:14:43 +00:00