Commit graph

29561 commits

Author SHA1 Message Date
Dylan Hunn
6238f7895f docs: Add a guide for typed forms. (#45939)
Create a new page, which describes the basic features of the new reactive forms types, and describes how to migrate to them.

PR Close #45939
2022-05-11 11:14:25 -07:00
Andrew Kushnir
b882d03068 docs: release notes for the v14.0.0-rc.0 release 2022-05-11 10:38:03 -07:00
Andrew Kushnir
e0a1a423fa docs: release notes for the v13.3.7 release 2022-05-11 10:25:09 -07:00
Ted.chang
5e6c574bd9 docs: add NGX-YOUI website to resources list (#45810)
PR Close #45810
2022-05-10 16:03:35 -07:00
Andrew Kushnir
eb3c96e7b1 test(core): reset Testability getter after each test (#45947)
This commit updates the Testability-related tests to reset the testability getter class after each test to avoid leaking the state between tests. This should improve the stability of the testability tests that are currently flaky on CI.

PR Close #45947
2022-05-10 16:02:53 -07:00
Renovate Bot
1a34b97e23 build: update angular to f557392 (#45941)
PR Close #45941
2022-05-10 13:36:11 -07:00
Andrew Kushnir
3165fa3f4e perf(platform-browser): avoid including Testability by default in bootstrapApplication (#45885)
The Testability-related logic was refactored in https://github.com/angular/angular/pull/45657 to become tree-shaking-friendly: it was decoupled from the core providers of the `BrowserModule`. This commit updates the newly-introduced `bootstrapApplication` function to exclude Testability-providers by default (note: the Testability is still included in the NgModule-based bootstrap).

In order to add the Testability to the app bootstrapped via `bootstrapApplication`, the `provideProtractorTestingSupport` function is introduced.

PR Close #45885
2022-05-10 13:34:28 -07:00
Dylan Hunn
e441ff44b4 fix(forms): Prevent FormBuilder from distributing unions to control types. (#45942)
Previously, using `FormBuilder` with a union type would produce unions of *controls*:

```
// `foo` has type `FormControl<string>|FormControl<number>`.
const c = fb.nonNullable.group({foo: 'bar' as string | number});
```

This actually works in many cases, due to how extraordinarily powerful Typescript's distributive types are (e.g. `value` still has type `string|number`), but it is subtly incorrect. Here is a code example that exposes the reason the inference is incorrect. It exploits the fact that Typescript will not "un-distribute" a type, producing an obviously spurious error:

```
// fc gets an inferred distributive union type `FormControl<string> | FormControl<number>`
let fc = c.controls.foo;
// Error: Type 'FormControl<string | number>' is not assignable to type 'FormControl<string> | FormControl<number>'.
fc = new FormControl<string|number>('', {initialValueIsDefault: true});
```

Instead, we want the union to apply to the *values*:

```
// `foo` should have type `FormControl<string|number>`.
const c = fb.nonNullable.group({foo: 'bar' as string | number});
```

Essentially, we want to prevent Typescript from distributing the type. [As specified in the handbook](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#distributive-conditional-types):

> Typically, distributivity is the desired behavior. To avoid that behavior, you can surround each side of the extends keyword with square brackets.

This PR applies this suggestion to `FormBuilder`'s type inference.

Fixes #45912.

PR Close #45942
2022-05-10 12:36:37 -07:00
Kristiyan Kostadinov
74321a45a0 refactor(core): remove ManualOnPush change detection (#45943)
We've had a TODO to expose ManualOnPush for a long time, but it hasn't moved since then. These changes remove it since it would be easy to re-introduce if we wanted to, it frees up an extra space in the flags bitmap and it removes some `render3` tests that we won't have to migrate to `TestBed`.

PR Close #45943
2022-05-10 09:37:07 -07:00
Andrew Scott
d48cfbca75 fix(language-service): Add resource files as roots to their associated projects (#45601)
When an external template is read, adds the template file to to the project which contains.
This is necessary to keep the projects open when navigating away from HTML files.
Since a `tsconfig` cannot express including non-TS files,
we need another way to indicate the template files are considered part of the project.

Note that this does not ensure that the project in question _directly_ contains the component
file. That is, the project might just include the component file through the program rather
than directly in the `include` glob of the `tsconfig`. This distinction is somewhat important
because the TypeScript language service/server prefers projects which _directly_ contain the TS
file (see `projectContainsInfoDirectly` in the TS codebase). What this means it that there can
possibly be a different project used between the TS and HTML files.

For example, in Nx projects, the referenced configs are `tsconfig.app.json` and
`tsconfig.editor.json`. `tsconfig.app.json` comes first in the base `tsconfig.json` and
contains the entry point of the app. `tsconfig.editor.json` contains the `**.ts` glob of all TS
files. This means that `tsconfig.editor.json` will be preferred by the TS server for TS files
but the `tsconfig.app.json` will be used for HTML files since it comes first and we cannot
effectively express `projectContainsInfoDirectly` for HTML files.

We could consider also updating the language server implementation to attempt
to select the project to use for the template file based on which project
contains its component file directly, using either the internal `project.projectContainsInfoDirectly`
or as a workaround, check `project.isRoot(componentTsFile)`.

Finally, keeping the projects open is hugely important in the solution style config case like
Nx. When a TS file is opened, TypeScript will only retain `tsconfig.editor.json` and not
`tsconfig.app.json`. However, if our extension does not also know to select
`tsconfig.editor.json`, it will automatically select `tsconfig.app.json` since it is defined
first in the `tsconfig.json` file. So we need to teach TS server that we are (1) interested in
keeping projects open when there is an HTML file open and (2) optionally attempt to do this
_only_ for projects that we know the TS language service will prioritize in TS files (i.e.,
attempt to only keep `tsconfig.editor.json` open and allow `tsconfig.app.json` to close)
and prioritize that project for all requests.

fixes https://github.com/angular/vscode-ng-language-service/issues/1623
fixes https://github.com/angular/vscode-ng-language-service/issues/876

PR Close #45601
2022-05-10 09:36:26 -07:00
Dylan Hunn
43ba4ab9da fix(forms): Allow NonNullableFormBuilder to be injected. (#45904)
Based on early feedback, calling `fb.nonNullable.group(...)` continues to be clunky for a form with many such groups. Allowing `NonNullableFormBuilder` to be directly injected enables the following:

```
constructor(private fb: NonNullableFormBuilder) {}
```

PR Close #45904
2022-05-09 17:31:48 -07:00
mgechev
216a966757 docs: simplify the DevTools readme and add publishing instructions (#45905)
Remove duplicate information. Add publishing instructions for Firefox
and Chrome.

PR Close #45905
2022-05-09 13:58:06 -07:00
mgechev
c08cee18b0 docs: add the change detection guide to the navigation and pullapprove (#45880)
PR Close #45880
2022-05-09 13:56:34 -07:00
mgechev
b968557682 docs: add a guide on using OnPush change detection strategy (#45880)
Explain how to use OnPush change detection strategy and what are the
different edge cases. Looks into several different scenarios and covers
the behavior of OnPush for each one of them.

PR Close #45880
2022-05-09 13:56:34 -07:00
mgechev
6283201363 docs: add a guide on optimizing slow computations (#45880)
Add a guide that explains:
- How we can slow the change detection down
- How to discover slow computations with Angular DevTools
- Explain how to fix slow computations

PR Close #45880
2022-05-09 13:56:34 -07:00
mgechev
428c2606c1 docs: add guide on how to run code outside of NgZone (#45880)
Explain the relationship between Angular and Zone.js. Covers how to
discover code that triggers change detection more often than we have to
run it and explain how to run code outside the Angular zone.

PR Close #45880
2022-05-09 13:56:34 -07:00
mgechev
01b819633d docs: add general change detection overview (#45880)
Add a few paragraphs with introduction to how change detection works
referencing a video for further details.

PR Close #45880
2022-05-09 13:56:34 -07:00
Andrew Kushnir
91b833a7f4 ci: enable the aio_preview CircleCI job (#45935)
This reverts commit dbc0dababa, since the fix has landed in c4340970c7.

PR Close #45935
2022-05-09 12:33:32 -07:00
JayMartMedia
0f0d01b023 docs: remove unnecesarry backslash from pipes documentation (#45916)
There was an extra backslash in the description of the pipe character. This could be misleading as people could think that the backslash is a pipe character.

PR Close #45916
2022-05-09 12:08:03 -07:00
JayMartMedia
3a5555f1a6 docs: fix bold text in start-data (#45916)
PR Close #45916
2022-05-09 12:08:03 -07:00
JoostK
75b3d0f843 perf(core): allow checkNoChanges mode to be tree-shaken in production (#45913)
This commit guards all logic that exists for the `checkNoChanges` mode
with `ngDevMode` checks such that the logic can be tree-shaken.

PR Close #45913
2022-05-09 12:04:04 -07:00
Cédric Exbrayat
def1f0fb93 refactor(core): declare TestModuleMetadata as an interface (#45891)
This allows the documentation for the options `errorOnUnknownElements` and `errorOnUnknownProperties` to be displayed in the docs.
They aren't currently displayed, as `TestModuleMetadata` is a type and not an interface.
See https://next.angular.io/api/core/testing/TestModuleMetadata

PR Close #45891
2022-05-09 11:56:18 -07:00
Andrew Kushnir
cd5a273edb ci: update NgBot to sync internal and external configs (#45915)
There was a difference in the set of paths between check/sync scripts internally and externally.
This commit aligns both configurations.

PR Close #45915
2022-05-09 11:55:37 -07:00
Thomas Mair
b5d78f4474 refactor(docs-infra): remove unnecessary types for stemmer dependency (#45831)
NOTE:
Since version 2.0.0 stemmer includes its own typings (see cd6fd9a031)

PR Close #45831
2022-05-09 11:54:55 -07:00
George Kalpakas
c4340970c7 fix(docs-infra): handle CircleCI API v2 responses in preview server (#45934)
In PR #45349 we switched to using version 2 of the CircleCI API. It
turns out that this version of the API (in addition to different URLs)
also returns different info from some endpoints, which we have failed to
account for.

More specifically, the v2 API response for a job does not contain info
that we need in [BuildRetriever][1].

As an example, see the API responses for an `aio_preview` run:
- [API v1.1][2]
- [API v2][3]

This commit updates the code to handle API v2 responses. In addition,
since the info we need is not present in the job info (as it was with
the previous version of the API), we now also retrieve the pipeline
info.

NOTE:
This issue did not manifest earlier, because the preview server code on
the VM was not updated to the latest version (that tried to use API v2)
due to a different error. This error was fixed with PR #45895, which
allowed the preview server to be updated on the VM and uncovered the API
v2 incompatibility.

[1]: baa3e18812/aio/aio-builds-setup/dockerbuild/scripts-js/lib/preview-server/build-retriever.ts (L39-L45)
[2]: https://circleci.com/api/v1.1/project/github/angular/angular/1163816
[3]: https://circleci.com/api/v2/project/gh/angular/angular/job/1163816

Fixes #45931

PR Close #45934
2022-05-09 11:54:08 -07:00
Andrew Kushnir
af253cc2ea ci: enable Android 12 for tests on CI (#45926)
This commit updates SauceLabs config to use Android 12 and drop Android 10, so we maintain 2 most recent versions according to https://angular.io/guide/browser-support.

Closes #45925.

PR Close #45926
2022-05-09 11:26:10 -07:00
dario-piotrowicz
b6156f41a6 docs(docs-infra): clarify toh-2 error message (#45878)
the second step of the tour of heroes refers to a runtime error which
generally isn't presented to new users since it gets caught by the
TypeScript compiler's strict mode, clarify such detail so not to confuse
readers

resolves #45759

PR Close #45878
2022-05-09 11:23:25 -07:00
George Kalpakas
e83775cc7f docs: fix code snippets in TOH (part 5) "Final code review" section (#45830)
Fixes #45736

PR Close #45830
2022-05-09 11:18:19 -07:00
George Kalpakas
2ed75324f3 docs: fix ellipsis in code-snippet in creating-libraries guide (#45820)
When hard-coding content in a `<code-example>` tag inside an `.md` file,
the content is treated as HTML by the Markdown processor and thus any
characters with special meaning in HTML have to be encoded (or replaced
with HTML entities).

However, the content that is embedded into `<code-example>` tags via
docregions is treated as text (since it is not parsed by the Markdown
processor) and thus should not have encoded characters or HTML entities.

PR Close #45820
2022-05-09 11:08:46 -07:00
Andrew Kushnir
dbc0dababa ci: disable aio_preview CircleCI job temporarily (#45932)
This commit disables the `aio_preview` CircleCI job temporarily, since it's failing after switching to CircleCI API v2. It will be enabled back once the code is updated. More info can be found here: https://github.com/angular/angular/issues/45931

PR Close #45932
2022-05-09 11:06:51 -07:00
ᚷᛁᛟᚱᚷᛁ ᛒᚨᛚᚨᚲᚻᚨᛞᛉᛖ
baa3e18812 docs: remove redundant word (#45910)
PR Close #45910
2022-05-06 09:52:19 -07:00
Paul Gschwendtner
ae7aee77ba ci: update github robot config to reflect update in syncing (#45907)
The `ng_module` Starlark code is not used internally, just
`ngc-wrapped`.

PR Close #45907
2022-05-06 09:51:46 -07:00
George Kalpakas
d4e949f45c fix(ngcc): cope with packages following APF v14+ (#45833)
In PR #45405, the Angular Package Format (APF) was updated so that
secondary entry-points (such as `@angular/common/http`) do not have
their own `package.json` file, as they used to. Instead, the paths to
their various formats and types are exposed via the primary
`package.json` file's `exports` property. As an example, see the v13
[@angular/common/http/package.json][1] and compare it with the v14
[@angular/common/package.json > exports][2].

Previously, `ngcc` was not able to analyze such v14+ entry-points and
would instead error as it considered such entry-points missing.

This commit addresses the issue by detecting this situation and
synthesizing a `package.json` file for the secondary entry-points based
on the `exports` property of the primary `package.json` file. This data
is only used by `ngcc` in order to determine that the entry-point does
not need further processing, since it is already in Ivy format.

[1]: https://unpkg.com/browse/@angular/common@13.3.5/http/package.json
[2]: https://unpkg.com/browse/@angular/common@14.0.0-next.15/package.json

PR Close #45833
2022-05-06 09:51:14 -07:00
George Kalpakas
400ec172ca refactor(ngcc): move loadPackageJson() and related types to utils.ts (#45833)
Move the `loadPackageJson()` helper (and associated generic types, such
as `JsonObject`) from `packages/entry_point.ts` to `utils.ts` and also
rename it to `loadJson()`. This way, they can be used in other places in
future commits, without introducing cyclical dependencies.

PR Close #45833
2022-05-06 09:51:14 -07:00
George Kalpakas
8467e9a499 refactor(ngcc): remove unused dependencies (#45833)
Remove some unused dependencies from `ngcc` source code.

PR Close #45833
2022-05-06 09:51:14 -07:00
dario-piotrowicz
3f3812e20a docs(docs-infra): improve clarity of toh-pt2 li>button code (#45858)
in the tour of heros part 2 guide the addition of a button with spans is
slighly unclear, so update the code to make things more clear

resolves #45760

PR Close #45858
2022-05-05 16:58:44 -07:00
mgechev
1a233c2c55 docs: update the Angular DevTools supported version in docs and README (#45902)
Ensure we document we support Angular v12 or older. Also remove Ivy as
a requirement because that's implicit.

PR Close #45902
2022-05-05 16:56:46 -07:00
Andrew Kushnir
0ffb19abed test(platform-browser): refactor flaky test (#45906)
This commit updates a flaky test related to the Testability. The tests are only flaky in Chrome on Android.

PR Close #45906
2022-05-05 16:56:12 -07:00
Andrew Kushnir
3e7d299157 ci: update the list of excluded paths in NgBot config (#45901)
This commit aligns the NgBot config that is used to determine whether a presubmit is needed with its internal version.

PR Close #45901
2022-05-05 15:45:47 -07:00
Paul Gschwendtner
a6b6590339 fix(bazel): speed up d.ts bundling by configuring worker (#45900)
Speeds up the `d.ts` bundling by configuring it as a Bazel
persistent worker. Also improve logging for the ng packager
rule to make it easier to spot which actions/bundles take
up significant time.

Type bundling will occur for every entry-point so for machines
with rather limited cores/threads, this will be useful to save
NodeJS boot and resolution time.

PR Close #45900
2022-05-05 15:35:14 -07:00
AleksanderBodurri
b7fca64828 build(devtools): Optimize prod build for Angular DevTools (#45886)
Uses `createEsbuildAngularOptimizePlugin` from dev-infra-private and passes in `GLOBAL_DEFS_FOR_TERSER_WITH_AOT` into a new esbuild prod configuration. Notably, this removes references to `ngDevMode` from the final build and enables minification.

PR Close #45886
2022-05-05 15:33:14 -07:00
mgechev
a212fb4dde docs: update the Angular DevTools auto-generated READMEs (#45884)
Replace the auto-generated READMEs in the different Angular DevTools
submodules with brief descriptions.

PR Close #45884
2022-05-05 15:29:27 -07:00
mgechev
136839054c refactor(devtools): remove support for v11 and older versions of Angular (#45883)
In Angular v12 we introduced debugging APIs sufficient for DevTools.
Prior to that Angular DevTools accesses the logical data structures of
Ivy directly, which sometimes produces suboptimal results and skips
dynamically inserted content.

With the end of v11's LTS, we'll support only Angular v12 and up.

PR Close #45883
2022-05-05 15:28:42 -07:00
George Kalpakas
b7be9e424b build(docs-infra): remove unused Docker artifacts when updating the preview server (#45895)
Update the `update-preview-server.sh` script that is used to update the
PR preview server to also remove unused Docker images and containers
after the update. This avoids having unused Docker artifacts grow
uncontrolled and fill up the VM disk drive.

PR Close #45895
2022-05-05 14:49:12 -07:00
George Kalpakas
0244cf771e test(docs-infra): update preview server serify-setup tests to match implementation (#45895)
Update the mocks used in the `verify-setup` tests of the PR preview
server to account for changes made in PR #45349. These tests run to
verify that a newly built docker container works as expected before
deploying it to the preview server, so having them fail prevents the
preview server from updating automatically.

NOTE:
These tests are currently not run on CI due to complications with
running Docker inside Docker.

PR Close #45895
2022-05-05 14:49:12 -07:00
Paul Gschwendtner
be7955d84e build: use vendored yarn script for installing Sass repositories (#45892)
Fixes the Bazel analysis warning and the fact that Yarn is unnecessarily
downloaded by `rules_nodejs`.

```
DEBUG: /home/circleci/.cache/bazel/_bazel_circleci/9ce5c2144ecf75d11717c0aa41e45a8d/external/build_bazel_rules_nodejs/index.bzl:73:14: yarn_install#yarn attribute not set and no repository named 'yarn' exists; installing default yarn
```

PR Close #45892
2022-05-05 13:56:38 -07:00
Will 保哥
a020872ec6 docs: fix a markdown syntax error in aio/content/marketing/analytics.md (#45898)
PR Close #45898
2022-05-05 11:50:56 -07:00
Andrew Kushnir
c9b40b5100 refactor(core): make Testability compatible with tree-shaking (#45657)
This commit refactors the `Testability`-related logic to extract the necessary providers into a separate array, so that it can later become it's own NgModule (or exposed as an array of providers) and be excluded from the new APIs by default.

PR Close #45657
2022-05-05 11:50:23 -07:00
Andrew Kushnir
d380bb49b7 refactor(core): rename internal bootstrap function (#45896)
This commit renames an internal function that implements the core bootstrap logic. The function is exported as a private symbol (with `ɵ`), but in order to avoid any possible confusion, we include "internal" into the function name as well.

PR Close #45896
2022-05-05 10:55:56 -07:00
Renovate Bot
0483c7487c build: update dependency @types/chrome to ^0.0.184 (#45849)
PR Close #45849
2022-05-05 10:16:12 -07:00