Commit graph

26080 commits

Author SHA1 Message Date
Kristiyan Kostadinov
1e30baaaa7 test: remove usages of deprecated runSchematicAsync function (#48745)
Removes our usages of `runSchematicAsync` since it is deprecated.

PR Close #48745
2023-01-17 09:13:39 -08:00
Kristiyan Kostadinov
5e5e7d79d0 build: update Angular packages to 15.1.0 stable (#48745)
Bumps up the Angular package dependencies to 15.1.0 stable.

PR Close #48745
2023-01-17 09:13:39 -08:00
Kristiyan Kostadinov
6beff5e8d7 refactor(compiler): rework and expose APIs to be used in schematics (#48730)
Reworks some of the existing compiler APIs to make them easier to use in a schematic and exposes a few new ones to surface information we already had. High-level list of changes:
* `getPotentialImportsFor` now requires a class reference, instead of a `PotentialDirective | PotentialPipe`.
* New `getNgModuleMetadata` method has been added to the type checker.
* New `getPipeMetadata` method has been added to the type checker.
* New `getUsedDirectives` method has been added to the type checker.
* New `getUsedPipes` method has been added to the type checker.
* The `decorator` property was exposed on the `TypeCheckableDirectiveMeta`. The property was already present at runtime, but it wasn't specified on the interface.

PR Close #48730
2023-01-13 12:24:32 -08:00
Pawel Kozlowski
5f21c6d627 perf(common): avoid excessive DOM mutation in NgClass (#48433)
This commit represents rewrite of the NgClass directive to address
severe performance problem (excessive DOM mutation). The modified
algorithm removes all the known performance clifs and has number of
desirable properties:
- it is shorter and (arguably) easier to follow;
- drops usage of existing differs thus limiting dependencies on other
part of the code without increasing size of the directive;
- doesn't degrade any other performance metrics.

Fixes #25518

PR Close #48433
2023-01-13 10:38:54 -08:00
Pawel Kozlowski
26686a3395 refactor(common): remove unnecessary curly brackets (#48433)
Remove unnecessary curly brackets in tests.

PR Close #48433
2023-01-13 10:38:54 -08:00
ced
5bb1223737 refactor(router): remove unused parameter in navigation internal function (#48724)
The internal `cancelNavigationTransition` required an unused `router` parameter.

PR Close #48724
2023-01-13 10:37:25 -08:00
Angular Robot
914e7b052e build: update actions/cache digest to 58c146c (#48564)
See associated pull request for more information.

PR Close #48564
2023-01-13 10:35:51 -08:00
Angular Robot
5b1c7c10a0 build: update dependency @rollup/plugin-commonjs to v24 (#48530)
See associated pull request for more information.

PR Close #48530
2023-01-13 10:35:19 -08:00
Angular Robot
d47bd480c9 build: update scorecard action dependencies (#48465)
See associated pull request for more information.

PR Close #48465
2023-01-13 10:34:47 -08:00
Angular Robot
f03f20c8ba build: update actions/checkout digest to ac59398 (#48460)
See associated pull request for more information.

PR Close #48460
2023-01-13 10:33:47 -08:00
Angular Robot
34dda890ed build: update io_bazel_rules_sass digest to 57ade09 (#48407)
See associated pull request for more information.

PR Close #48407
2023-01-13 10:32:34 -08:00
Paul Gschwendtner
13f10de40e test: update code fixes spec to work with esm-cjs interop lint (#48731)
The TSLint rule for ESM/CJS interop was apparently not working
for a short period of time due to diverging TypeScript versions.

This commit fixes the lint warning to replace the type-only
import with a default import. Even thoughn not striclty needed
for types- the rule enforces a default import as that is the safer
approach for runtime imported symbols.

Also the rule is updated to not disallow `cluster` anymore. The
types for cluster do no allow for e.g. `cluster.Worker` if cluster
refers to the default import. The whole lint rule is not strictly
needed anymore since we build & test with ESM in this repo now!

PR Close #48731
2023-01-13 14:10:39 +00:00
Paul Gschwendtner
1898190c28 build: update ng-dev and account for stamping changes (#48731)
* updates ng-dev and build-tooling since the previous SHAs are
no longer existent after the CircleCI incident snapshot build removal.
* accounts for the new stamping variables.

PR Close #48731
2023-01-13 14:10:39 +00:00
Alex Rickabaugh
f00bf71411 fix(core): makeEnvironmentProviders should accept EnvironmentProviders (#48720)
`makeEnvironmentProviders` constructs the wrapped `EnvironmentProviders`
type, which can only be used in environment injectors (not element
injectors). It makes sense that `makeEnvironmentProviders` should be able
to accept existing `EnvironmentProviders`-wrapped providers, since it will
be providing the same guarantee, but the current types do not allow this.

This commit fixes the typings to allow nesting `EnvironmentProviders` and
adds a test to verify that it will work.

PR Close #48720
2023-01-12 13:47:59 -08:00
Dylan Hunn
4ae384fd61 feat(language-service): Allow auto-imports of a pipe via quick fix when its selector is used, both directly and via reexports. (#48354)
A previous PR introduced a new compiler abstraction that tracks *all* known exports and re-exports of Angular traits. This PR harnesses that abstraction in the language service, in order to allow automatic imports of pipes.

PR Close #48354
2023-01-12 13:46:46 -08:00
Dylan Hunn
141333411e feat(language-service): Introduce a new NgModuleIndex, and use it to suggest re-exports. (#48354)
NgModules can re-export other NgModules, which transitively includes all traits exported by the re-exported NgModule. We want to be able to suggest *all* re-exports of a component when trying to auto-import it.

Previously, we used an approximation when importing from NgModules: we looked at a Component's metadata, and just imported the declaring NgModule. However, this is not technically correct -- the declaring NgModule it is not necessarily the same one that exports it for the current scope. (Indeed, there could be multiple re-exports!) As a replacement, I have implemented a more general solution.

This PR introduces a new class on the template type checker, called `NgModuleIndex`. When queried, it conducts a depth-first-search over the NgModule import/export graph, in order to find all NgModules anywhere in the current dependency graph, as well as all exports of those NgModules. This allows the language service to suggest all of the re-exports, in addition to the original export.

PR Close #48354
2023-01-12 13:46:46 -08:00
Dylan Hunn
ea8b33934b refactor(compiler-cli): Make getKnown return an array of nodes. (#48354)
`MetadataReaderWithIndex.getKnown` currently returns an iterator. It will be easier to work with for upcoming usages if it returns an array instead.

PR Close #48354
2023-01-12 13:46:46 -08:00
Dylan Hunn
2a4c5b4391 refactor(language-service): Improve the quick fix auto-import tests. (#48354)
Currently, the auto-import tests are very difficult to debug, because the `expect`ations are buried several function calls deep, and also because the multi-line replacements are hard to deal with. The auto-import tests now use a different approach, which can be easily debugged from the failure message. In addition, several new tests have been added to cover more cases.

PR Close #48354
2023-01-12 13:46:46 -08:00
Konstantin Kharitonov
8802b4aab9 fix(common): Update Location to get a normalized URL valid in case a represented URL starts with the substring equals APP_BASE_HREF (#48489)
```ts
@NgModule({
  imports: [RouterModule.forRoot([{path: '/enigma', component: EnigmaComponent}])],
  providers: [{provide: APP_BASE_HREF, useValue: '/en'}]
})
export class AppModule {}
```

Navigating to `/enigma` will redirect to `/en/igma` not to `/en/enigma` as it expects

Fixes: #45744

PR Close #48489
2023-01-12 11:45:32 -08:00
Paul Gschwendtner
64967da78a ci: include branch name in update CLI help PRs (#48716)
This should make it easier to distinguish between PRs
as currently they same equivalent but actually target
different branches.

PR Close #48716
2023-01-12 11:44:51 -08:00
Bob Watson
0b57e24eb6 docs: add first-app-lesson-13 example (#48512)
PR Close #48512
2023-01-12 11:44:07 -08:00
Bob Watson
1edf5874d7 docs: add first-app-lesson-12 example (#48512)
PR Close #48512
2023-01-12 11:44:07 -08:00
Bob Watson
d2333b4d35 docs: add first-app-lesson-11 example (#48512)
PR Close #48512
2023-01-12 11:44:07 -08:00
Bob Watson
25ec456b9f docs: add first-app-lesson-10 example (#48512)
PR Close #48512
2023-01-12 11:44:07 -08:00
Bob Watson
d894e40dd5 docs: add first-app-lesson-09 example (#48512)
PR Close #48512
2023-01-12 11:44:07 -08:00
Bob Watson
b3283bd271 docs: add first-app-lesson-08 example (#48512)
PR Close #48512
2023-01-12 11:44:06 -08:00
Bob Watson
76daeb6ff7 docs: add first-app-lesson-07 example (#48512)
PR Close #48512
2023-01-12 11:44:06 -08:00
Bob Watson
3344d839bf docs: add first-app-lesson-06 example (#48512)
PR Close #48512
2023-01-12 11:44:06 -08:00
Bob Watson
a19888cf06 docs: add first-app-lesson-05 example (#48512)
PR Close #48512
2023-01-12 11:44:06 -08:00
Bob Watson
af3947d2b1 docs: add first-app-lesson-04 example (#48512)
PR Close #48512
2023-01-12 11:44:06 -08:00
Bob Watson
3519651f72 docs: add first-app-lesson-03 example (#48512)
PR Close #48512
2023-01-12 11:44:06 -08:00
Bob Watson
f7eef20a52 docs: add first-app-lesson-02 example (#48512)
PR Close #48512
2023-01-12 11:44:06 -08:00
Bob Watson
dd8a5d56e3 docs: add first-app-lesson-01 example (#48512)
PR Close #48512
2023-01-12 11:44:05 -08:00
Matthieu Riegler
4dcbb6aef9 refactor(forms): replace type any for the providers (#48647)
The providers for the directives in forms can be typed as Provider. Also the export is not required.

PR Close #48647
2023-01-11 15:01:57 -08:00
Andrew Scott
926c35f4ac docs: Deprecate class and InjectionToken and resolvers (#47924)
Class and `InjectionToken`-based guards and resolvers are not as configurable,
are less re-usable, require more boilerplate, cannot be defined inline with the route,
and require more in-depth knowledge of Angular features (`Injectable`/providers).
In short, they're less powerful and more cumbersome.

In addition, continued support increases the API surface which in turn increases
bundle size, code complexity, the learning curve and API surface to teach,
maintenance cost, and cognitive load (needing to grok several different types
of information in a single place).

Lastly, supporting only the `CanXFn` types for guards and `ResolveFn` type
for resolvers in the `Route` interface will enable better code
completion and integration with TypeScript. For example, when writing an
inline functional resolver today, the function is typed as `any` and
does not provide completions for the `ResolveFn` parameters. By
restricting the type to only `ResolveFn`, in the example below
TypeScript would be able to correctly identify the `route` parameter as
`ActivatedRouteSnapshot` and when authoring the inline route, the
language service would be able to autocomplete the function parameters.

```
const userRoute: Route = {
  path: 'user/:id',
  resolve: {
    "user": (route) => inject(UserService).getUser(route.params['id']);
  }
};
```

Importantly, this deprecation only affects the support for class and
`InjectionToken` guards at the `Route` definition. `Injectable` classes
and `InjectionToken` providers are _not_ being deprecated in the general
sense. Functional guards are robust enough to even support the existing
class-based guards through a transform:

```
function mapToCanMatch(providers: Array<Type<{canMatch: CanMatchFn}>>): CanMatchFn[] {
  return providers.map(provider => (...params) => inject(provider).canMatch(...params));
}
const route = {
  path: 'admin',
  canMatch: mapToCanMatch([AdminGuard]),
};
```

With regards to tests, because of the ability to map `Injectable`
classes to guard functions as outlined above, nothing _needs_ to change
if projects prefer testing guards the way they do today. Functional
guards can also be written in a way that's either testable with
`runInContext` or by passing mock implementations of dependencies.
For example:

```
export function myGuardWithMockableDeps(
  dep1 = inject(MyService),
  dep2 = inject(MyService2),
  dep3 = inject(MyService3),
) { }

const route = {
  path: 'admin',
  canActivate: [() => myGuardWithMockableDeps()]
}

// test file
const guardResultWithMockDeps = myGuardWithMockableDeps(mockService1, mockService2, mockService3);
const guardResultWithRealDeps = TestBed.inject(EnvironmentInjector).runInContext(myGuardWithMockableDeps);
```

DEPRECATED: Class and `InjectionToken` guards and resolvers are
deprecated. Instead, write guards as plain JavaScript functions and
inject dependencies with `inject` from `@angular/core`.

PR Close #47924
2023-01-11 15:01:08 -08:00
Angular Robot
7f68a709a7 docs: update Angular CLI help (#48704)
Updated Angular CLI help contents.

Closes #48701

PR Close #48704
2023-01-11 15:00:21 -08:00
Andrew Scott
8375a8c9a8 docs: Add heading to the router writable properties deprecation (#48684)
The deprecation note is missing a header. This commit adds one.

PR Close #48684
2023-01-11 14:59:04 -08:00
mgechev
f09b6e4507 docs: add angular devsat q1 2023 (#48683)
PR Close #48683
2023-01-11 14:58:35 -08:00
Jens
01be0e2874 docs: Add support for previous Chrome release (#48669)
Previous Chrome stable version should also be supported
PR Close #48669
2023-01-11 14:57:44 -08:00
Matthieu Riegler
518cc63022 docs: remove unused style guides. (#48587)
PR Close #48587
2023-01-11 14:57:09 -08:00
Bob Watson
7281dbc913 docs: minor copy edit to suggestion (#48484)
PR Close #48484
2023-01-11 14:56:31 -08:00
Bob Watson
874f197720 docs: minor copy edit to suggestion (#48484)
PR Close #48484
2023-01-11 14:56:31 -08:00
Bob Watson
84285c1ef8 docs: minor copy edit to suggestion (#48484)
PR Close #48484
2023-01-11 14:56:31 -08:00
Bob Watson
1c4eb67354 docs: minor copy edit to suggestion (#48484)
PR Close #48484
2023-01-11 14:56:30 -08:00
Aristeidis Bampakos
deb27df160 docs: review router guards section in router guide (#48484)
PR Close #48484
2023-01-11 14:56:30 -08:00
dario-piotrowicz
61023b563d refactor(compiler): refactor the shadow css specs (#48443)
apply different quality of life improvements to the shadow
css unit tests:

- refactor the tests so that they are nicely divided in multiple files
   in a logical manner instead of having most of them all in a single big file

- remove the css normalization logic inconsistently used throughout  the tests, which
  causes tests to be inconsistent and it also introduced unintuitive checks

- provide a shared shim utility function (instead of re-defining it
  multiple times)

- add a `toEqualCss` matcher that can be used in the tests in order to
  match css strings without caring about spacing and indentation

PR Close #48443
2023-01-11 14:55:52 -08:00
Angular Robot
fda96a6fc9 build: update dependency puppeteer-core to v19 (#48183)
See associated pull request for more information.

PR Close #48183
2023-01-11 14:55:17 -08:00
ノウラ
1cb93ce4e1 docs: highlight scripts in markdown (#47778)
This PR highlights all lines of code/cmds/error messages by specifying the use language

PR Close #47778
2023-01-11 14:54:45 -08:00
Vladyslav Slipchenko
b0318f8b39 docs(docs-infra): fix wording inconsistency of the i18n common prepare section references (#47582)
PR Close #47582
2023-01-11 14:54:08 -08:00
Alex Rickabaugh
fbcddb092f release: cut the v15.2.0-next.0 release 2023-01-11 08:05:22 -08:00