Commit graph

29561 commits

Author SHA1 Message Date
Kristiyan Kostadinov
7343ec7913 refactor(core): remove unused module tracking (#47066)
We used to track all modules in a top-level constant called `autoRegisterModuleById` which was used by `getRegisteredNgModuleType`. As of #45024 the constant isn't being used anymore so we can remove it.

PR Close #47066
2022-08-08 11:32:16 -07:00
Roman Matusevich
4ae8b2e12c docs: fix text formatting for paragraph in Hierarchical injectors (#47067)
Paragraph of text is not wrapped into `p` tag due to missing empty line after the `div` block. The fix is just add an empty line.

PR Close #47067
2022-08-08 11:31:44 -07:00
Pawel Kozlowski
7f992326e4 docs: update link to the TypeScript handbook (#47075)
Closes #47070
PR Close #47075
2022-08-08 11:31:18 -07:00
Paul Gschwendtner
2548214ba2 ci: invalidate circleci caches to prune nested node_modules (#46707)
Yarn 1.x. is known to not prune nested unused node modules. This throws
off Bazel when the dependency tree changes but there are leftover unused
nested node module folders. This causes CI failures currently after the
dependency tree updates.

Invalidating the cache fixes this issue. Long-term a switch to Yarn
2.x+, pnpm will fix this.

PR Close #46707
2022-08-08 09:23:56 -07:00
Angular Robot
ab9ce8a008 build: update all non-major dependencies (#46707)
See associated pull request for more information.

PR Close #46707
2022-08-08 09:23:56 -07:00
Andrew Kushnir
3ef4d8a690 refactor(core): drop unused animation-related types (#47054)
This commit removes animation-related types that are no longer used after the `RootContext` cleanup.

PR Close #47054
2022-08-08 09:23:30 -07:00
Jan Melcher
561cd84901 docs: fix link in dependency injection guide (#47055)
PR Close #47055
2022-08-08 09:23:06 -07:00
Andrew Scott
0abb67af59 feat(router): allow guards and resolvers to be plain functions (#46684)
The current Router APIs require guards/resolvers to be present in the DI tree. This is because we want to treat all guards/resolvers equally and some may require dependencies. This requirement results in quite a lot of boilerplate for guards. Here are two examples:

```
const MY_GUARD = new InjectionToken<any>('my_guard');
…
providers: {provide: MY_GUARD, useValue: () => window.someGlobalState}
…
const route = {path: 'somePath', canActivate: [MY_GUARD]}
```

```
@Injectable({providedIn: 'root'})
export class MyGuardWithDependency {
  constructor(private myDep: MyDependency) {}

  canActivate() {
    return myDep.canActivate();
  }
}
…
const route = {path: 'somePath', canActivate: [MyGuardWithDependency]}
```

Notice that even when we want to write a simple guard that has no dependencies as in the first example, we still have to write either an InjectionToken or an Injectable class.

With this commit router guards and resolvers can be plain old functions.
 For example:

```
const route = {path: 'somePath', component: EditCmp, canDeactivate: [(component: EditCmp) => !component.hasUnsavedChanges]}
```

Additionally, these functions can still use Angular DI with `inject` from `@angular/core`.

```
const route = {path: 'somePath', canActivate: [() => inject(MyDependency).canActivate()]}
```

PR Close #46684
2022-08-05 10:36:46 -07:00
ileil
0920a15139 docs: update dependency injection content (#44466)
Refactored the DI section to improve doc quality, reduce cognitive load and drive consistency.

- Added an overview with prerequisites and doc cards that point to rest of the DI content
- Added introduction topic with topic purpose, value proposition and "fail fast"
- Broke apart complex concepts into simpler tasks
- Unified tone and language for each topic
- Added new content based on SME feedback
- Deleted obsolete content

PR Close #44466
2022-08-05 10:06:13 -07:00
Andrew Kushnir
c1ad37d161 refactor(core): drop unused fields from the RootContext (#46806)
The `RootContext` implementation contained a number of fields that were needed to support an experimental `renderComponent` function. The `renderComponent` function was removed, which allows us to cleanup the `RootContext` further.

The only field that remains on the `RootContext` is the list of bootstrapped components. This list is presumably mostly unused right now (it just contains the current component) and further refactoring can happen in a followup PR.

PR Close #46806
2022-08-05 09:58:06 -07:00
Angular Robot
f6c57e856b build: update io_bazel_rules_sass digest to 697e5a0 (#47046)
See associated pull request for more information.

PR Close #47046
2022-08-05 09:57:45 -07:00
Paul Gschwendtner
0b392afb69 build: update ngsw-config.json after redirect changes (#47048)
Looks like the `ngsw-config.json` file needs to be updated after a new
redirect being added in: https://github.com/angular/angular/pull/46820.

PR Close #47048
2022-08-05 09:56:56 -07:00
Paul Gschwendtner
9d9def3303 refactor(docs-infra): update safevalues and account for API changes (#47048)
Updates `safevalues` to unblock
https://github.com/angular/angular/pull/46707. As part of this commit
the necessary refactorings due to API changes are also made.

PR Close #47048
2022-08-05 09:56:56 -07:00
Victor Porof
f23232ff66 feat(zone.js): Update to the simpler Async Stack Tagging v2 API (#46958)
Signed-off-by: Victor Porof <victorporof@chromium.org>

PR Close #46958
2022-08-04 14:25:35 -07:00
Andrew Kushnir
2b4d7f6733 feat(platform-server): support document reference in render functions (#47032)
This commit updates the `renderModule` and `renderApplication` functions to also accept a document reference (in addition to the serialized document contents as a string). This should provide the necessary flexibility to NgUniversal (and other API consumers) to structure the logic to avoid serializing and parsing document multiple times during the SSR request.

PR Close #47032
2022-08-04 13:37:54 -07:00
Angular Robot
de1e28006b build: update io_bazel_rules_sass digest to 70ffe01 (#47023)
See associated pull request for more information.

PR Close #47023
2022-08-04 13:08:42 -07:00
ashide2729
c360b43add docs: add yarn build fail workaround on windows (#47037)
PR Close #47037
2022-08-04 13:08:19 -07:00
George Kalpakas
f9b30df156 ci: fix Renovate post-upgrade task command (#47040)
Since Renovate runs from the project directory, it cannot find the
`sync-deps` yarn script inside `aio/tools/examples/shared/`:
[example failure][1]

Update the post-upgrade task command to run inside that directory
instead of the project root.

[1]: https://github.com/angular/angular/pull/46707#issuecomment-1203335639

PR Close #47040
2022-08-04 13:07:55 -07:00
Paul Gschwendtner
c01ccc5582 test: update ngtsc closure fileoverview tests to reflect suppression updates (#47018)
tsickle has updated some of the suppressions. See for example:
19ee2d6938

PR Close #47018
2022-08-03 17:36:18 -07:00
Paul Gschwendtner
7a3e200e7b build: temporarily patch @bazel/concatjs to unblock tsickle update (#47018)
Temporary patch until
https://github.com/bazelbuild/rules_nodejs/pull/3517 is available in
another `rules_nodejs` release.

We can remove this patch, but for now it doesn't hurt. On the external
side the tsickle code path is not hit at all anyway, but we need to
satisfy the TypeScript checker.

PR Close #47018
2022-08-03 17:36:18 -07:00
Paul Gschwendtner
ea89677c12 feat(compiler-cli): support more recent version of tsickle (#47018)
Updates the tsickle version in the repository and accounts for its changes in
the `compiler-cli` package. Tsickle made a breaking change in the minor version
segment bump that would break the use with `@angular/compiler-cli`

Additionally the tsickle version for `@angular/bazel` is updated since
we updated `@bazel/typescript` to also account for the breaking changes.

See: 78a0528107

PR Close #47018
2022-08-03 17:36:18 -07:00
Jessica Janiuk
f42a7c5234 docs(core): Add docs for keyboard event binding (#47022)
This adds new documentation on how to bind to keyboard events for key and code fields, and why you might use one over the other.

PR Close #47022
2022-08-03 17:35:56 -07:00
Bob Watson
ed15427f19 docs: update Vale installation instructions (#47031)
This update includes:
* installation directions for the current version of the Vale VSCode extension (v. 0.15.0)
* a workaround for if the current version of the extension doesn't work.

PR Close #47031
2022-08-03 17:35:30 -07:00
Andrew Kushnir
7e491cfab3 fix(docs-infra): do not require @ngModule tag on standalone types (#47024)
This commit updates docs extraction logic to avoid requiring the `@ngModule` tag on standalone types, since they don't have to be present in any NgModule.

PR Close #47024
2022-08-03 11:04:55 -07:00
Andrew Kushnir
6fabc0c679 release: cut the v14.2.0-next.0 release 2022-08-03 10:57:01 -07:00
Andrew Kushnir
71b4ccd70c docs: release notes for the v14.1.1 release 2022-08-03 10:50:22 -07:00
Andrew Scott
9e3994c7cc docs(core): Update inject error documentation (#47020)
The inject function is also available when using EnvironmentInjector.runInContext.

PR Close #47020
2022-08-02 18:06:55 -07:00
Angular Robot
cb42788785 build: update eslint dependencies to v5.32.0 (#47016)
See associated pull request for more information.

PR Close #47016
2022-08-02 11:59:42 -07:00
George Kalpakas
7243564499 build(docs-infra): ensure all boilerplate dependencies are in sync (#47009)
All docs examples share the same `node_modules/` (symlinked into each
example from `aio/tools/examples/shared/node_modules/`). However, each
example type has a different `package.json`, which comes from
`aio/tools/examples/shared/boilerplate/*`). In order to ensure that the
dependencies in each example's `package.json` are the same as the ones
in the symlinked `node_modules/` (i.e. the ones that CI tests are run
with), we have a script (`yarn run sync-deps`) that can sync
dependencies from `shared/package.json` into the boilerplate
`package.json` files.

Previously, this script had to be run manually, which was easy to
forget/not know about and resulted in the boilerplate dependencies
often being out-of-sync with the ones in `shared/package.json` (and by
extension, the ones that were actually installed in `node_modules/`).

This commit helps keep the boilerplate dependencies up-to-date in the
following ways:
- Adds the `sync-deps` script to the `postinstall` scripts.
  This ensures that dependencies remain in sync whenever someone
  manually updates dependencies in `shared/package.json`.
- Runs the `sync-deps` script as a Renovate post-upgrade task.
  This ensures that the depenencies remain in sync whenever Renovate
  updates dependencies in `shared/package.json`.
  For more info on configuring post-upgrade tasks in Renovate, see:
  - [postUpgradeTasks][1]
  - [allowedPostUpgradeCommands][2]
  - [allowPostUpgradeCommandTemplating][3]

NOTE:
For the Renovate change to take effect, the [global config][4] in
`angular/dev-infra` also needs to be updated. This will be done in a
separate PR.

[1]: https://docs.renovatebot.com/configuration-options/#postupgradetasks
[2]: https://docs.renovatebot.com/self-hosted-configuration/#allowedpostupgradecommands
[3]: https://docs.renovatebot.com/self-hosted-configuration/#allowpostupgradecommandtemplating
[4]: 22d3067021/.github/ng-renovate/runner-config.js

PR Close #47009
2022-08-02 11:58:51 -07:00
ivanwonder
598b72bd05 feat(language-service): support fix the component missing member (#46764)
The diagnostic of the component missing member comes from the ts service,
so the all code fixes for it are delegated to the ts service.

The code fixes are placed in the LS package because only LS can benefit from
it now, and The LS knows how to provide code fixes by the diagnostic and NgCompiler.

The class `CodeFixes` is useful to extend the code fixes if LS needs to
provide more code fixes for the template in the future. The ts service uses
the same way to provide code fixes.

1622247636/src/services/codeFixProvider.ts (L22)

Fixes https://github.com/angular/vscode-ng-language-service/issues/1610

PR Close #46764
2022-08-02 11:58:21 -07:00
Andrew Scott
d8cf78ba5e fix(router): Do not call preload method when not necessary (#47007)
In Angular 14, we introduced the `loadComponent` API for a `Route` to
allow lazy loading of a routed component in addition to the existing
`loadChildren` which allows lazy loading of child routes. As a result,
the `preload` method of the `PreloadingStrategy` needs to sometimes be
called even when there is a `canLoad` guard on the `Route`. `CanLoad`
guards block loading of child routes but _do not_ block loading of the
component.

This change updates the conditional checks in the internal preloader to
skip calling the `PreloadingStrategy.preload` when there is only a
`loadChildren` callback with a `canLoad` guard an no `loadComponent`.
In this case, the callback passed to the `preload` method is already
effectively a no-op so it's not necessary to call it at all.

resolves #47003

PR Close #47007
2022-08-02 09:38:28 -07:00
Paul Gschwendtner
b757b1387c build: update dev-infra packages and account for build-tooling split from ng-dev (#46976)
The dev-infra build tooling is now decoupled from `ng-dev`. This will
make it easier to update `ng-dev` without necessarily needing to upgrade
the whole build system, Bazel etc. This is useful when e.g. new release
tool features have been added and should also be ported to active LTS
branches.

PR Close #46976
2022-08-02 09:37:37 -07:00
Andrew Scott
1fe759d9a4 refactor(common): Align PathLocationStrategy constructor with default factory (#46929)
When using the Angular Router, one of `APP_BASE_HREF` or a `<base>` in
the header must be provided. When _not_ using the `RouterModule`,
injecting the `LocationStrategy` will result in the
`PathLocationStrategy` being provided with a default value used in place
of `APP_BASE_HREF` that is `document?.location?.origin ?? ''`.

It can be quite surprising and annoying that once you add `RouterModule`
to the application, suddenly the `APP_BASE_HREF` must be specifically
provide something new when it could use a sensible default instead.

The current behavior (before this commit) is as follows:

* When `RouterModule` is not provided (or the dev doesn't specifically provide
  `PathLocationStrategy`): use `DOCUMENT.location?.origin ?? ''`.
  Note that the base href in the dom and `APP_BASE_HREF` are not used.
* When `RouterModule` _is_ provided:
   1. APP_BASE_HREF if defined
   2. Get base href from DOM
   3. throw if neither of the two above are defined

This commit updates this behavior to be aligned regardless of `RouterModule`
usage. The order (by default) is now:
  1. Developer provided `APP_BASE_HREF`
  2. base href from the DOM
  3. `location.origin`
  4. If none of the above exist, use `''`

This is slightly different than the behavior before. However, I believe
it is more appropriate. For the case without `RouterModule`, it would
likely be surprising that `APP_BASE_HREF` and the base href from the DOM
are ignored by default. For the case with `RouterModule`, we now have a
more sensible fallback/default when neither `APP_BASE_HREF` nor `<base>`
are defined (instead of just throwing an error).

PR Close #46929
2022-08-01 14:21:14 -07:00
Marek Hám
57d4628e1f docs: fix link to live example (#47011)
Fixes #46975

PR Close #47011
2022-08-01 14:20:36 -07:00
Durairaj Subramaniam
2123317d02 docs: fix link in routing (#46988)
PR Close #46988
2022-08-01 13:00:24 -07:00
Angular Robot
f47c93ba3f build: update bazel setup to v5.5.3 (#47000)
See associated pull request for more information.

PR Close #47000
2022-08-01 12:55:44 -07:00
Ilia Mirkin
e2ab99b95e fix(common): allow null/undefined to be passed to ngClass input (#39280) (#46906)
With strict template type checking, a null/undefined value will raise an
error. However the implementation is completely fine with it, and it
would be pointless to "fix" it at the callsite and convert to e.g. an
empty string. Allow all of the "supported types" to be passed in
directly to ngClass.

Fixes #39280

PR Close #46906
2022-08-01 12:55:13 -07:00
Andrew Scott
f364378e4d fix(router): Use correct return type for provideRoutes function (#46941)
The provideRoutes function of the Router returns a Provider array and should not be typed as 'any'

PR Close #46941
2022-08-01 11:20:49 -07:00
Andrew Scott
8600732b09 feat(router): Expose the default matcher for Routes used by the Router (#46913)
This commit adds the `defaultUrlMatcher` from the Router to the public
API. `UrlMatcher` and `UrlMatchResult` are already in the public api so
the signature of the function as well as the return value are already
exposed. Any change to those or the implementation of `defaultUrlMatcher`
would already be breaking so there's no additional risk in exposing the
default matcher.

This function can be useful for developers who want to create a custom
matcher which builds on the default matcher of the Router. Currently,
the only way to do this would be to copy-paste the implementation.

fixes #35928

PR Close #46913
2022-08-01 11:19:33 -07:00
Andrew Scott
55febc1691 refactor(router): Remove unused ANALYZE_FOR_ENTRY_COMPONENTS (#46942)
`entryComponents` is a feature that is not used or necessary in Angular
anymore.

PR Close #46942
2022-08-01 11:18:09 -07:00
Roman Matusevich
6fc52c5cba docs: fix selector in Component Interaction guide (#46995)
The selector for the `CountdownTimerComponent` is `app-countdown-timer`
not `countdown-timer`.

PR Close #46995
2022-08-01 11:16:30 -07:00
Asaf M
4ac2196695 docs: fixed typos (#47008)
Used my script: https://github.com/Uziel302/websites-spell-checker/blob/master/mdnversion

PR Close #47008
2022-08-01 11:15:54 -07:00
J Rob Gant
af4f5df150 refactor(zone.js): remove leftover debugging code using Error.stack (#46989)
Pull request #46672 added some debugging code to trace down the
root cause of its bug, but parts of the debugging code has never
been cleaned up and ended up landing as part of the PR.

This commit removes the code as it might cause unexpected issues.
Likely when e.g. `Error` is patched and would perform XHRs in testing,
unveiling e.g. CORS issues. See #46989.

PR Close #46989
2022-08-01 09:52:29 -07:00
George Kalpakas
99e5fa157d test(service-worker): remove redundant ternary operator from MockRequest initialization (#46912)
Since the `init` parameter has a default value of `{}`, it can never be
`!== undefined`. Thus, it is not necessary to account for that case.

PR Close #46912
2022-08-01 09:51:56 -07:00
George Kalpakas
3b34254932 docs(service-worker): remove duplication when describing notificationclick operations (#46912)
PR Close #46912
2022-08-01 09:51:56 -07:00
Tristan Sprößer
383090858c feat(service-worker): support sendRequest as a notificationclick action (#46912)
Implement a new `notificationclick` action, `sendRequest`, which sends a
GET request to the specified URL, without opening a new window. This can
be useful for hitting an API endpoint.

PR Close #46912
2022-08-01 09:51:55 -07:00
Cédric Exbrayat
49e1912e1d refactor(compiler-cli): remove unused error codes (#46847)
A few codes were unused, or no longer used.

PR Close #46847
2022-08-01 09:50:12 -07:00
Kristiyan Kostadinov
ac6e7fa97e fix(bazel): allow extendedDiagnostics option to be passed in through tsconfig (#46953)
Adds the `extendedDiagnostics` field to the list of allowed options so that it is picked up from the user's tsconfig.

PR Close #46953
2022-08-01 09:49:14 -07:00
George Kalpakas
f386cdb499 refactor(docs-infra): remove code that prints debug info (#46987)
In #41106, code was added in angular.io to print info that would help us
investigate and debug a ServiceWorker issue (#28114). Since the fix for
the issue was deployed on October 6th, 2021, the related error rate has
dropped dramatically:

![ChunkLoadError rate](https://user-images.githubusercontent.com/8604205/181502119-64ffb5de-f38e-4414-abcd-0fada29fd6d5.png)

Additionally, there have been no known occurrences or reports of the
issue in the last several months.

The remaining occurrences could be attributed to older versions still
being around on people's devices (due to the ServiceWorker caching) and
other circumstances not related to the ServiceWorker, for which there is
not much we can do. For example, a user could keep a tab open with an
older version of the app, which requests hashed files that no longer
exist on the server. If the ServiceWorker is not activated on such a tab
(either because the browser does not support it or because the user has
disabled it, for example), then it is expected that these requests would
fail.

This commit removes the code that prints ServiceWorker-related debug
info to reduce the payload size of the app.

Fixes #41117

PR Close #46987
2022-08-01 09:48:14 -07:00
Angular Robot
996071035b build: update eslint dependencies to v5.31.0 (#46968)
See associated pull request for more information.

PR Close #46968
2022-08-01 09:46:41 -07:00