Commit graph

25416 commits

Author SHA1 Message Date
Alex Rickabaugh
c5a1b90b25 refactor(core): support EnvironmentProviders types internally (#47669)
This commit modifies `R3Injector` and other code in Angular that deals with
providers, to handle `EnvironmentProviders` objects as well as normal
`Provider` types. There is no user-visible impact to this change, but it
prepares the core of the DI system for the introduction of
`EnvironmentProviders` as a public feature.

PR Close #47669
2022-10-07 14:03:13 -07:00
Alex Rickabaugh
3133351f25 refactor(core): define shape of EnvironmentProviders interface (#47669)
This commit introduces the `EnvironmentProviders` interface, but does not
yet export it as public API.

PR Close #47669
2022-10-07 14:03:13 -07:00
Bob Watson
deb4cabe2e docs: update spelling dictionary (#47697)
PR Close #47697
2022-10-07 11:45:32 -07:00
Bob Watson
33dc1e602f docs: remove assorted lint errors (#47693)
PR Close #47693
2022-10-07 10:42:12 -07:00
Andrew Kushnir
7bee28d037 feat(router): add a migration to remove relativeLinkResolution usages (#47604)
As of Angular v15, the deprecated `relativeLinkResolution` config option of the Router is removed.  This migration cleans up (removes) the `relativeLinkResolution` fields from the Router config objects in applications code.

```ts
import { RouterModule } from '@angular/router';

RouterModule.forRoot([], {
  relativeLinkResolution: 'legacy',
  enableTracing: false,
});
```

```ts
import { RouterModule } from '@angular/router';

RouterModule.forRoot([], {
  // the `relativeLinkResolution` is removed
  enableTracing: false,
});
```

PR Close #47604
2022-10-07 10:28:42 -07:00
Paul Gschwendtner
739e689630 build: setup remote execution through shared command (#47537)
Sets up remote execution through a shared command.

PR Close #47537
2022-10-07 09:31:30 -07:00
Matthias Weiß
bdb5371033 feat(common): add injection token for default DatePipe configuration (#47157)
This commit introduces a new `DATE_PIPE_DEFAULT_OPTIONS` token, which
can be used to configure default DatePipe options, such as date
format and timezone.

DEPRECATED:

The `DATE_PIPE_DEFAULT_TIMEZONE` token is now deprecated in favor
of the `DATE_PIPE_DEFAULT_OPTIONS` token, which accepts an object
as a value and the timezone can be defined as a field (called `timezone`)
on that object.

PR Close #47157
2022-10-07 09:16:00 -07:00
Charles Lyding
a792bf1703 perf(compiler-cli): minimize filesystem calls when generating shims (#47682)
Previously when a file was being analyzed to determine if a shim should
be generated, up to two calls to the host `fileExists` function per file
per generator were made. In the default host, each `fileExists` call made
two underlying file system calls. Following these calls, the file was then
read via `getSourceFile`. However, `getSourceFile` will return `undefined`
if the requested file does not exist. As a result, `getSourceFile` can be
used directly to request both potential file names and leverage the return
value to determine if the file does not exist. This avoids the need to call
`fileExists` at all.

PR Close #47682
2022-10-07 09:10:34 -07:00
Alex Rickabaugh
ea16a98dfe fix(http): better handle unexpected undefined XSRF tokens (#47683)
`HttpXsrfTokenExtractor` allows returning `string|null` for an XSRF token,
and the interceptor checked if the returned token is `null`. However, some
implementations return `undefined` instead (behind an `any`) type, which
caused the interceptor to crash when trying to set an `undefined` value for
the header.

This commit makes the XSRF interceptor a little more resilient against such
broken implementations of the `HttpXsrfTokenExtractor` interface.

PR Close #47683
2022-10-06 16:41:06 -07:00
Renan Ferro
84478f5a1c refactor(docs-infra): add new Input for better description of close button in notification component (#47681)
Add a new input for banner description with default value, allowing the insertion of other descriptions and if nothing is passed, it assumes a default value.

PR Close #47681
2022-10-06 16:23:42 -07:00
markostanimirovic
8d1f28a024 docs: add Marko to GDE resources (#47595)
PR Close #47595
2022-10-06 14:23:32 -07:00
Peter Dickten
214baeae8b docs: fixed typo in AsyncValidatorFn (#47465)
the return type must be
Observable<ValidationErrors | null>
instead of
Observable<ValidationErrors> | null

PR Close #47465
2022-10-06 14:00:49 -07:00
Mathew Berg
5377e35b53 docs: fix documentation linting errors in ajs-quick-reference.md (#47526)
PR Close #47526
2022-10-06 20:27:26 +00:00
Álvaro Martínez
bf6679a579 docs(forms): setErrors emitEvent default value (#47546)
PR Close #47546
2022-10-06 20:24:52 +00:00
Andrew Kushnir
7032910d17 ci: cleanup PullApprove config file (#47611)
This commit updates the PullApprove config file.

PR Close #47611
2022-10-06 20:04:53 +00:00
Alex Rickabaugh
c09c1bb033 docs(http): fix copy-paste error in HttpClientJsonpModule docs (#47502)
This commit deletes a sentence from the `HttpClientJsonpModule` docs which
was accidentally copy-pasted from the docs for another symbol.

PR Close #47502
2022-10-06 19:02:46 +00:00
Alex Rickabaugh
3ba99e286a feat(http): allow for child HttpClients to request via parents (#47502)
Ordinarily, providing `HttpClient` (either via `provideHttpClient` or the
`HttpClientModule`) creates an entirely separate HTTP context. Requests made
via that client are not passed through the interceptor chains that are
configured in a parent injector, for this example.

This commit introduces a new option for `provideHttpClient` called
`withRequestsMadeViaParent()`. When this option is passed, requests made in
the child context flow through any injectors, etc. and are then handed off
to the parent context.

This addresses a longstanding issue with interceptors where it's not
possible to extend the set of interceptors in a child context without
repeating all of the interceptors from the parent.

PR Close #47502
2022-10-06 19:02:46 +00:00
Alex Rickabaugh
62c7a7a16e feat(http): introduce functional interceptors (#47502)
This commit introduces a new feature for `provideHttpClient` called
`withInterceptors`. This feature exposes and configures the new concept of
functional interceptors.

Functional interceptors use functions instead of classes to implement an
HTTP interceptor. Such interceptor functions have access to the DI context
from the `EnvironmentInjector` in which they're configured via the
`inject()` function. Otherwise, functional interceptors are identical in
capability to the existing interceptor system.

PR Close #47502
2022-10-06 19:02:46 +00:00
Alex Rickabaugh
fc69c8021c refactor(http): convert NgModules to use provideHttpClient internally (#47502)
This commit converts `HttpClientModule` to use `provideHttpClient()`
internally, with a particular configuration of features. Other NgModules
related to configuring `HttpClient` are also converted to use the providers
directly from various features, to ensure consistency of behavior.

PR Close #47502
2022-10-06 19:02:45 +00:00
Alex Rickabaugh
e47b129070 feat(http): introduce the provideHttpClient() API (#47502)
This commit introduces the main components of the `provideHttpClient()`
provider API, designed in the style of `provideRouter()`. Initial features
are defined for including legacy class-based interceptors, JSONP support,
and configuring or disabling the builtin XSRF protection.

This API is an alternative to providing `HttpClient` via the
`HttpClientModule`, and is more tree-shakable and more capable than the
NgModule implementation.

Tests are included to validate the new configuration format as well as the
interoperability of the two styles of providing and configuring
`HttpClient`.

PR Close #47502
2022-10-06 19:02:45 +00:00
Alex Rickabaugh
84d0d33c35 feat(http): introduce provideHttpClientTesting provider function (#47502)
This commit introduces the `provideHttpClientTesting()` function as an
alternative to the `HttpClientTestingModule` (in fact, the NgModule is
converted internally to just use the new provider function).

PR Close #47502
2022-10-06 19:02:45 +00:00
Alex Rickabaugh
67ef8b19b3 refactor(http): convert the XSRF interceptor to functional style (#47502)
This commit converts the XSRF interceptor into a functional interceptor
instead of a legacy class-based interceptor.

PR Close #47502
2022-10-06 19:02:45 +00:00
Alex Rickabaugh
ab6a3d7d03 refactor(http): provide XSRF configuration tokens in root (#47502)
This commit switches the XSRF configuration tokens (for header name and
cookie name) to be `providedIn: 'root'`. This is a no-op change now as they
are always provided along with any usage of them via `HttpClientModule`, but
will become load-bearing as the `provideHttpClient` API will not provide
these tokens, and will rely on injecting them from either the parent context
or from these root providers.

PR Close #47502
2022-10-06 19:02:45 +00:00
Alex Rickabaugh
d98d8d7645 refactor(http): use an InjectionToken to disable the XSRF interceptor (#47502)
@angular/common/http has XSRF protection which is enabled by default and is
implemented as an interceptor. Previously, this protection could be disabled
with an API which would internally provide a `NoopInterceptor` in place of
the standard XSRF interceptor.

To achieve the same capability of disabling the XSRF interceptor after it is
converted to the functional style, an InjectionToken is added in this commit
which disables the XSRF interceptor. This way, the interceptor can be
disabled in place without needing to override it via DI (which is difficult
for functional interceptors).

PR Close #47502
2022-10-06 19:02:45 +00:00
Alex Rickabaugh
c3ecd8f5c8 refactor(http): convert the JSONP interceptor to the functional style (#47502)
This commit rewrites the JSONP interceptor to use the functional interceptor
style internally, while still maintaining the same public API and behavior.

PR Close #47502
2022-10-06 19:02:45 +00:00
Alex Rickabaugh
546f9ca299 refactor(http): use a DI token for new interceptors (#47502)
This commit introduces a new DI token for the set of functional
interceptors. This is a no-op in terms of behavior currently, but will allow
for the deduplication of the bridge interceptor which connects legacy class-
based interceptors to the functional interceptor chain.

PR Close #47502
2022-10-06 19:02:45 +00:00
Alex Rickabaugh
d7683a611a refactor(http): introduce the functional interceptors API (#47502)
This commit introduces new types and symbols related to functional HTTP
interceptors - interceptors which are plain functions with access to DI via
the `inject()` operation.

This new form of interceptor is not exposed publically in this commit, but
the legacy class-based interceptors are refactored to be built on top of the
new API internally.

PR Close #47502
2022-10-06 19:02:45 +00:00
Andrew Kushnir
16c8f55663 feat(router): migrate RouterLinkWithHref references to RouterLink (#47599)
Since Angular v15, the `RouterLink` contains the logic of the `RouterLinkWithHref` directive and now developers can always import and use the `RouterLink` directive when they need to add a `[routerLink]` in templates. This migration finds all imports and usages of the `RouterLinkWithHref` class and rewrites them to `RouterLink` instead.

```ts
import { RouterLinkWithHref } from '@angular/router';

@Component({
  standalone: true,
  template: `<a [routerLink]="'/abc'">`,
  imports: [RouterLinkWithHref]
})
export class MyComponent {
  @ViewChild(RouterLinkWithHref) aLink!: RouterLinkWithHref;
}
```

```ts
import { RouterLink } from '@angular/router';

@Component({
  standalone: true,
  template: `<a [routerLink]="'/abc'">`,
  imports: [RouterLink]
})
export class MyComponent {
  @ViewChild(RouterLink) aLink!: RouterLink;
}
```

PR Close #47599
2022-10-06 18:57:37 +00:00
Kristiyan Kostadinov
db28badfe6 feat(core): enable the new directive composition API (#47642)
Enables the new directive composition API by exposing the `hostDirectives` property on the `Directive` and `Component` decorators. Also cleans up some casts that were put in place while the feature was being developed.

Fixes #8785.

PR Close #47642
2022-10-06 18:11:45 +00:00
WD Snoeijer
7702a3d4af docs: fix linter errors for lightweight-injection-tokens.md (#47673)
PR Close #47673
2022-10-06 18:10:34 +00:00
Angular Robot
e0dd2c53c2 build: update cross-repo angular dependencies (#47600)
See associated pull request for more information.

PR Close #47600
2022-10-06 16:53:39 +00:00
WD Snoeijer
5d002df47b docs: fix linter errors for lazy-loading-ngmodules.md (#47645)
Update aio/content/guide/lazy-loading-ngmodules.md

Co-authored-by: Bob Watson <104218420+bob-watson@users.noreply.github.com>

PR Close #47645
2022-10-06 16:50:00 +00:00
WD Snoeijer
fcea8fe377 docs: fix linter errors for libraries.md (#47668)
PR Close #47668
2022-10-06 16:48:39 +00:00
Andrew Scott
cf88a3ce20 build: add atscott to unavailable list for pullapprove (#47658)
atscott is unavailable to review PRs until no longer OOO

PR Close #47658
2022-10-06 16:05:20 +00:00
Andrew Kushnir
f73ef21442 feat(router): merge RouterLinkWithHref into RouterLink (#47630)
This commit updates the `RouterLink` to extend the selector to also include `<a>` and `<area>` elements, which were previously matched by the `RouterLinkWithHref` directive. The code of the directives was merged together (since there was a lot of duplication) and this commit finalizes the merge. The `RouterLinkWithHref` becomes an alias of the `RouterLink` directive.

Now there is no need to import and use the `RouterLinkWithHref` class, the `RouterLink` directive will match any element that has the `routerLink` attribute.

DEPRECATED:

The `RouterLinkWithHref` directive is deprecated, use the `RouterLink` directive instead. The `RouterLink` contains the code from the `RouterLinkWithHref` to handle elements with `href` attributes.

PR Close #47630
2022-10-05 15:16:43 -07:00
Dylan Hunn
8df8c77915 refactor(compiler): Add getPotentialImportsFor method on template type checker (#47631)
`getPotentialImportsFor` returns an array of possible imports, including TypeScript module specifier and identifier name, for a requested trait in the context of a given component.

PR Close #47631
2022-10-05 13:44:05 -07:00
WD Snoeijer
0035ccfe93 docs: fix linter errors for angular-compiler-options.md page (#47179) (#47618)
fixup! docs: fix linter errors for angular-compiler-options.md page (#47179)

PR Close #47618
2022-10-05 13:43:24 -07:00
Martin Probst
19ad4987f9 fix(compiler-cli): use @ts-ignore. (#47636)
The previous commit 2e1dddec45 used `@ts-expect-error` to suppress the
current error, with the intent of being informed once that's no longer
an error, ie. when we updated to an upstream TS version that includes
this change.

However this unfortunately means the change is incompatible with the
fixed version, which prevents it from working with an updated TS version
in google3.

This change reverts back to the original `@ts-ignore` which is forwards
and backwards compatible, avoiding that problem (but unfortunately
losing the benefit of being notified once fixed).

PR Close #47636
2022-10-05 13:37:11 -07:00
Andrew Scott
7b89d95c0e fix(router): Remove deprecated relativeLinkResolution (#47623)
The `relativeLinkResolution` is no longer supported. The only behavior
now is the correct behavior.

BREAKING CHANGE: `relativeLinkResolution` is no longer configurable in
the Router. This option was used as a means to opt out of a bug fix.

PR Close #47623
2022-10-05 08:57:28 -07:00
Andrew Kushnir
2cdf1286e3 release: cut the v15.0.0-next.5 release 2022-10-05 08:50:18 -07:00
Andrew Kushnir
8352cf7d14 docs: release notes for the v14.2.5 release 2022-10-05 08:43:32 -07:00
Andrew Kushnir
ab4ef264ed refactor(router): drop own constructor from the RouterLinkWithHref class (#47619)
This commit updates the `RouterLinkWithHref` class to further align with the `RouterLink` class by removing own constructor from the `RouterLinkWithHref` class.

PR Close #47619
2022-10-04 16:21:35 -07:00
Andrew Scott
2f0761000f test(router): Ensure change detection runs after navigation (#47629)
Components are not fully rendered until change detection runs.

PR Close #47629
2022-10-04 16:19:32 -07:00
Alex Rickabaugh
da58801f95 feat(router): auto-unwrap default exports when lazy loading (#47586)
When using `loadChildren` or `loadComponent`, a common pattern is to pass
a function that returns a `Promise` from a dynamic import:

```typescript
{
  path: 'lazy',
  loadComponent: () => import('./lazy-file').then(m => m.LazyCmp),
}
```

The `.then` part of the expression selects the particular exported
component symbol from the dynamically imported ES module.

ES modules can have a "default export", created with the `export default`
modifier:

```typescript
@Component({...})
export default class LazyCmp { ... }
```

This default export is made available to dynamic imports under the well-
known key of `'default'`, per the ES module spec:
https://tc39.es/ecma262/#table-export-forms-mapping-to-exportentry-records

This commit adds a feature to the router to automatically dereference such
default exports. With this logic, when `export default` is used, a `.then`
operation to select the particular exported symbol is no longer required:

```typescript
{
  path: 'lazy',
  loadComponent: () => import('./lazy-file'),
}
```

The above `loadComponent` operation will automatically use the `default`
export of the `lazy-file` ES module.

This functionality works for `loadChildren` as well.

PR Close #47586
2022-10-04 14:40:58 -07:00
Alex Rickabaugh
a2a066d325 refactor(router): organize deprecated loadChildren code (#47586)
This commit breaks out the code in @angular/router needed to support the
deprecated `loadChildren` signature into a separate file, which reduces the
opportunity for conflicts when patching that behavior in g3.

PR Close #47586
2022-10-04 14:40:58 -07:00
Dylan Hunn
29194638c1 refactor(compiler): Rename PipeInScope -> PotentialPipe (#47561)
Now that `getPotentialTemplateDirectives` uses `PotentialDirective`, we should rename `PipeInScope` to match.

PR Close #47561
2022-10-04 14:40:04 -07:00
Dylan Hunn
79c016d433 refactor(compiler): Add getPotentialTemplateDirectives API method. (#47561)
`getPotentialTemplateDirectives` returns possible directives which can be used in the provided context, whether already in scope or requiring an import.

This is necessary to implement auto-import support for standalone components in the language service.

PR Close #47561
2022-10-04 14:40:04 -07:00
Dylan Hunn
3783ee01ac refactor(compiler): Rename DirectiveInScope -> PotentialDirective (#47561)
After implementing `getPotentialTemplateDirectives`, we will use this data struture to represent both in-scope and out-of-scope directives. So this rename is an advance cleanup.

PR Close #47561
2022-10-04 14:40:04 -07:00
Alex Rickabaugh
e3cef4a784 docs(core): deprecate providedIn: NgModule and providedIn: 'any' (#47616)
This commit deprecates the above two forms of `providedIn`.

DEPRECATED:

- The ability to pass an `NgModule` to the `providedIn` option for
`@Injectable` and `InjectionToken` is now deprecated.

`providedIn: NgModule` was intended to be a tree-shakable alternative to
NgModule providers. It does not have wide usage, and in most cases is used
incorrectly, in circumstances where `providedIn: 'root'` should be
preferred. If providers should truly be scoped to a specific NgModule, use
`NgModule.providers` instead.

- The ability to set `providedIn: 'any'` for an `@Injectable` or
`InjectionToken` is now deprecated.

`providedIn: 'any'` is an option with confusing semantics and is almost
never used apart from a handful of esoteric cases internal to the framework.

PR Close #47616
2022-10-04 11:52:38 -07:00
Jordan
7ab10a5031 docs: add Jordan Powell to GDE resources (#47598)
PR Close #47598
2022-10-04 11:52:04 -07:00