8343 Commits

Author SHA1 Message Date
Paul Gschwendtner 1d204fcf2c Revert "test(common): Fix flaky Location test (#45683)" (#45691)
This reverts commit 254d6cea9a.

This test has only been introduced in the next branch with
https://github.com/angular/angular/pull/44901. The cherry-pick
of the flaky test fix does not work in the patch branch due to
some other missing changes and the test did not exist in 13.3.x
anyway.

PR Close #45691
2022-04-20 08:58:46 -07:00
Andrew Scott 254d6cea9a test(common): Fix flaky Location test (#45683)
This test has proven to be flaky. This commit greatly simplifies the
test and moves it to a more appropriate location (pun intended).

PR Close #45683
2022-04-19 20:17:56 -07:00
Andrew Kushnir ed832b4dd7 test: reset counters before running a styling test (#45670)
This commit updates one of the styling tests to reset perf counters, making it order-independent and non-flaky (previously the test got random failures depending on whether there are other tests invoked before).

PR Close #45670
2022-04-19 09:14:10 -07:00
Kristiyan Kostadinov 9317f513d5 fix(core): better error message when directive extends a component (#45658)
We throw an error when a directive is trying to extend a component, but we don't actually say which class is responsible which can be difficult to track down. These changes add the two class names to the error message.

PR Close #45658
2022-04-18 09:24:24 -07:00
ivanwonder d68333e508 fix(language-service): two-way binding completion should not remove the trailing quote (#45582)
We allow the path to contain both the `t.BoundAttribute` and `t.BoundEvent` for two-way
bindings but do not want the path to contain both the `t.BoundAttribute` with its
children when the position is in the value span because we would then logically create a path
that also contains the `PropertyWrite` from the `t.BoundEvent`. This early return condition
ensures we target just `t.BoundAttribute` for this case and exclude `t.BoundEvent` children.

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

PR Close #45582
2022-04-15 13:53:49 -07:00
Andrew Kushnir 4766817f02 fix(core): improve multiple components match error (#45645)
This commit improves the error message that is thrown at runtime when multiple components match the same element. Now the error message contains names of classes that represent those components.

PR Close #45645
2022-04-15 13:52:20 -07:00
Andrew Kushnir 575cafc163 test(core): add a test for multiple named interpolations with the same name (#45651)
The test from this commit verifies that i18n logic can handle multiple named interpolations with the same name.

PR Close #45651
2022-04-15 13:51:56 -07:00
Andrew Kushnir ec115a31b8 refactor(core): avoid referencing PlatformRef in bootstrap code (#45519)
This commit updates an existing bootstrap logic to avoid referencing the `PlatformRef` instance to keep track of the platform status. Instead, we use platform injector, so that the `PlatformRef`can be tree-shaken away in the bootstrap logic for Standalone Components.

The motivation for this change is that retaining the `PlatformRef` class also retains NgModule-based bootstrap code, which would not be needed in case of Standalone Components.

PR Close #45519
2022-04-13 15:34:48 -07:00
Kristiyan Kostadinov e50fd9ee87 fix(compiler): avoid errors with extremely long instruction chains (#45574)
Our logic for generating code from an AST uses recursion which limits the number of expressions we can nest before we reach the call stack limit. These changes add a limit in order to avoid errors in some cases where the chains become extremely long.

Fixes #45564.

PR Close #45574
2022-04-13 16:18:56 +00:00
Andrew Kushnir fc145d024b refactor(core): make ComponentFactoryResolver lazily instantiated in ApplicationRef (#45507)
This commit removes the `ComponentFactoryResolver` as a constructor argument of the `ApplicationRef` class. This makes it lazily instantiated + simplifies further refactoring in a context of Standalone Components.

PR Close #45507
2022-04-12 22:29:17 +00:00
Andrew Kushnir 44b9d89917 refactor(core): make platform core providers tree-shakable (#45506)
This commit refactors the set of hardcoded platform core providers into tree-shakable providers.
In addition to making them tree-shakable, this would also avoid the need to rely on the platform creation logic in an upcoming bootstrap logic for Standalone Components.

PR Close #45506
2022-04-12 22:28:24 +00:00
Joe Martin (Crowdstaffing) 61894570f1 docs: improve markdown (#45590)
improve markdown for documentation. Duplicate of #45325 that targets 13.3.x.

PR Close #45590
2022-04-11 22:35:01 +00:00
Renovate Bot 09c5c18c7d build: update dependency google-closure-compiler to v20220405 (#45568)
PR Close #45568
2022-04-11 16:26:26 +00:00
Cédric Exbrayat 208d81921d refactor(core): validate property (#45528)
Simplifies and documents the `validateProperty` function (in a similar fashion that #45492 simplified `validateElementIsKnown`).

PR Close #45528
2022-04-07 22:03:13 +00:00
Hossein Mousavi dbd6e75b37 docs(forms): remove the incorrect set value from previous commit (#45533)
in the validators documentation, the value for the formControl for both required and requiredTrue validators is an empty string. This is OK for required since it gives us an error. But I think if we set the value of formControl responsible for requiredTrue to something other than an empty string (e.g.: 'some value'), it would demonstrate the difference between required and requiredTrue better.

PR Close #45533
2022-04-07 21:00:26 +00:00
Hossein Mousavi 6a5ee688df docs(forms): add value to formControl for better demonstration of requiredTrue validator (#45533)
in the validators documentation, the value for the formControl for both required and requiredTrue validators is an empty string. This is OK for required since it gives us an error. But I think if we set the value of formControl responsible for requiredTrue to something other than an empty string (e.g.: 'some value'), it would demonstrate the difference between required and requiredTrue better.

PR Close #45533
2022-04-07 21:00:26 +00:00
Andrew Kushnir 05121c0381 test(animations): update test to use an object instead of a Map (#45531)
The code in the patch branch is slightly different from the master branch: the master branch contains some changes where Map are used instead of objects in animations. As a result, one of the tests is failing in patch, since it expects Maps, but receives objects.

PR Close #45531
2022-04-05 10:31:48 -07:00
Christoph Guttandin a92bceda54 test(animations): add test for buildAnimationAst() function (#31107)
This commit adds a test for the buildAnimationAst() function.

PR Close #31107
2022-04-05 08:41:40 -07:00
Christoph Guttandin b46b25c562 fix(animations): handle structured AnimateTimings (#31107)
This commit makes sure structured AnimateTimings are not procesed any further when building the AST.

Fixes: #22752

PR Close #31107
2022-04-05 08:41:40 -07:00
Cédric Exbrayat 9fcc1b7758 refactor(core): validate element is known in JIT mode (#45492)
Renames, simplifies and documents the function in charge of validating if an element is known in JIT mode.

PR Close #45492
2022-04-04 09:34:42 -07:00
JoostK 7f53c0f4ac fix(compiler-cli): handle inline type-check blocks in nullish coalescing extended check (#45478)
This commit fixes an inconsistency where a type check location for an inline
type check block would be interpreted to occur in a type-checking shim instead.
This resulted in a missing template mapping, causing a crash due to an unsafe
non-null assertion operator.

In the prior commit the `TcbLocation` has been extended with an `isShimFile`
field that is now being used to look for the template mapping in the correct
location. Additionally, the non-null assertion operator is refactored such
that a missing template mapping will now ignore the warning instead of crashing
the compiler.

Fixes #45413

PR Close #45478
2022-03-30 11:34:41 -07:00
JoostK 3f55567111 refactor(compiler-cli): track whether a TcbPosition corresponds with a shim file (#45478)
Extends `TcbPosition` with a field that indicates whether the `tcbPath` is a
type-checking shim file, or an original source file with an inline type check
block.

This field is used in an upcoming commit that fixes an inconsistency with how
inline type check blocks are incorrectly interpreted as a type-checking shim
file instead.

PR Close #45478
2022-03-30 11:34:41 -07:00
JoostK fa90c74a73 refactor(compiler-cli): rename ShimLocation to TcbLocation (#45478)
Inline type check blocks (TCBs) are emitted into the original source file, but
node positions would still be represented as a `ShimLocation` with a `shimPath`
corresponding with the type-checking shim file. This results in inconsistencies,
as the `positionInShimFile` field of `ShimLocation` would not correspond with
the `shimPath` of that `ShimLocation`.

This commit is a precursor to letting `ShimLocation` also represent the correct
location for inline type check blocks, by renaming the interface to
`TcbLocation`. A followup commit addresses the actual inconsistency.

PR Close #45478
2022-03-30 11:34:41 -07:00
Paul Gschwendtner 63539489da test: update api goldens to reflect api-golden bazel rule change (#45469)
The API golden Bazel rule has changed in the shared dev-infra code. Instead
of putting golden API reports into the golden folder as per their original
location in the NPM package, golden reports are now stored based on the
package exports. This makes it more obvious how entry-points are consumable

As part of this change, since the API golden rule now consutls the NPM package
`exports` field, the `localize/tools` entry-point golden file is now generated.

Previously it wasn't generated due to it not having a secondary entry-point
`package.json` file. Such package json files should not be needed anymore
and will be gone in future APF versions.

PR Close #45469
2022-03-29 13:13:08 -07:00
JiaLiPassion c08705899f fix(zone.js): should ignore multiple resolve call (#45283)
Close #44913

The following case is not handled correctly by `zone.js`.
```
const delayedPromise = new Promise((resolve) => {
  setTimeout(resolve, 1, 'timeout');
});

new Promise((resolve) => {
  resolve(delayedPromise);
  resolve('second call');
}).then(console.log);
```

It should output `timeout`, since the promise is resolved by the
1st resolve, the `second call` should be ignored.

So this is a bug that the original implementation not ensure the
`resolve` is only called once.

PR Close #45283
2022-03-25 17:31:04 -07:00
arturovt 0dd532bcd6 fix(zone.js): swallow the error when the element callback is not patchable (#45400)
The `patchCallbacks` is used for patching the `document.registerElement` and
`customElements.define`. We explicitly wrap the patching code into try-catch since
callbacks may be already patched by other web components frameworks (e.g. LWC), and they
make those properties non-writable. This means that patching callback will throw an error
`cannot assign to read-only property`. See this code as an example:
https://github.com/salesforce/lwc/blob/master/packages/@lwc/engine-core/src/framework/base-bridge-element.ts#L180-L186
We don't want to stop the application rendering if we couldn't patch some
callback, e.g. `attributeChangedCallback`.

PR Close #42546

PR Close #45400
2022-03-25 16:31:10 -07:00
Paul Gschwendtner 88dbeda931 build: shorten partial compilation test case target names for windows (#45443)
Shortens the partial compilation test case target names as the paths/
manifest paths in Bazel became too large, exceeding some Windows path
length limits.

Relevant context/resources:
* https://angular-team.slack.com/archives/C02PARQNMC1/p1648137933069659 (internal)
* https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=cmd
* https://github.com/bazelbuild/rules_nodejs/pull/3215/files#r782271592

PR Close #45443
2022-03-25 13:45:08 -07:00
Paul Gschwendtner c24ea4b4f5 test: refactor compiler-cli compliance test to work on windows (#45443)
Recent changes in `rules_nodejs` caused the test case copy file actions
to be transitioned into the `exec` configuration, resulting in much larger
file paths. These paths break on Windows with the shell argument limit, and
with the path limit, causing errors like:

```
ERROR: C:/users/circleci/ng/packages/compiler-cli/test/compliance/test_cases/BUILD.bazel:9:12: Copying file packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/structural_directives_if_directive_def.js failed: (Exit 1): cmd.exe failed: error executing command
  cd /d C:/users/circleci/_bazel_circleci/u4uoan2j/execroot/angular
  SET PATH=C:\Program Files\Git\usr\bin;C:\Program Files\Git\bin;C:\Windows;C:\Windows\System32;C:\Windows\System32\WindowsPowerShell\v1.0
    SET RUNFILES_MANIFEST_ONLY=1
  cmd.exe /C bazel-out\x64_windows-opt-exec-2B5CBBC6\bin\packages\compiler-cli\test\compliance\test_cases\test_cases--1973427149-cmd.bat
The system cannot find the path specified
```

https://app.circleci.com/pipelines/github/angular/angular/44038/workflows/4b530cb2-f232-4e1d-b35a-e6e085151d08/jobs/1140017

PR Close #45443
2022-03-25 13:45:07 -07:00
Paul Gschwendtner 3f5e685ca9 refactor: remove unused variables in starlark code to satisfy buildifier (#45443)
We updated buildifier and a few warnings became errors now. This commit
cleans up the failing unused variable instances, making the linter happy.

Additionally for the API extractor BUILD file, the package defaults
need to move to satisfy buildifier.

PR Close #45443
2022-03-25 13:45:07 -07:00
Paul Gschwendtner 69e4c9813e build: migrate more usages from @bazel/typescript to @bazel/concatjs (#45443)
As mentioned in previous commits (check them for more details), `@bazel/typescript`
no longer contains `ts_library`-specific code, so we no longer need that dependency.

PR Close #45443
2022-03-25 13:45:07 -07:00
Paul Gschwendtner 1eaaa5d1cc refactor(bazel): update api-extractor to account for @bazel/typescript change (#45443)
`@bazel/typescript` code moved to `@bazel/concatjs` for the tsc-wrapped code.

Note that this code is likely going to be removed anyway soon when we
move dts bundling from `ng_module` to `ng_package`.

PR Close #45443
2022-03-25 13:45:07 -07:00
Paul Gschwendtner 1a149bb50d refactor(bazel): update ngc-wrapped to account for tsc-wrapped move to @bazel/concatjs (#45443)
Previously `tsc-wrapped` which is the foundation for `ngc-wrapped`, resided
in `@bazel/typescript`. It has been moved to `@bazel/concatjs` in rules_nodejs
so we need to account for that as part of our rules_nodejs v5 update.

PR Close #45443
2022-03-25 13:45:07 -07:00
Renovate Bot 29d4b78ada build: update bazel (#45443)
Update `@bazel` packages to the latest 5.x version.

Some of the changes here are modeled after
angular/dev-infra@40c0ac8559.

Co-Authored-By: George Kalpakas <kalpakas.g@gmail.com>

PR Close #45443
2022-03-25 13:45:06 -07:00
arturovt dbd6be829f fix(zone.js): read Symbol.species safely (#45369)
We must read `Symbol.species` safely because `this` may be anything. For instance, `this`
may be an object without a prototype (created through `Object.create(null)`); thus
`this.constructor` will be undefined. One of the use cases is SystemJS creating
prototype-less objects (modules) via `Object.create(null)`. The SystemJS creates an empty
object and copies promise properties into that object (within the `getOrCreateLoad`
function). The zone.js then checks if the resolved value has the `then` method and invokes
it with the `value` context. Otherwise, this will throw an error: `TypeError: Cannot read
properties of undefined (reading 'Symbol(Symbol.species)')`.

PR Close #45369
2022-03-24 18:56:37 -07:00
arturovt 2b0da62937 fix(zone.js): check if process is defined when patching the GlobalErrors.install (#45392)
Jasmine checks internally if `process` and `process.on` is defined. Otherwise,
it installs the browser rejection handler through the `global.addEventListener`.
This code may be run in the browser environment where `process` is not defined, and
this will lead to a runtime exception since Webpack 5 removed automatic Node.js polyfills.

PR Close #42260

PR Close #45392
2022-03-24 10:52:35 -07:00
Paul Gschwendtner 960e42b2ac fix(bazel): ng module compilation workers are subject to linker race-conditions (#45393)
The Bazel NodeJS rules provide two ways of accessing node modules:

* A linker which creates a `node_modules` directory in the execroot/or in the runfiles.
* A patched module resolution where no node modules directory necessarily needs to exist.

The first is the default in `rules_nodejs` and the second is technically the most idiomatic
resolution mechanism in Bazel (as it matches with a runfile resolution library).

The linker is prone to race conditions in persistent workers, or non-sandbox environments (like
windows). This is because the linker for all workers will operate on a shared `execroot` directory
and the same `node_modules` directory is modified all the time / potentially conflicting with other
linker processes from other concurrently-running workers.

We rely on the patched module resolution anyway, but just need to disable the unused linker to avoid
issues like the following:

```
---8<---8<--- Start of log, file at /private/var/tmp/_bazel_splaktar/280f06d55552a0d01f89f0955b5acd78/bazel-workers/worker-8-TypeScriptCompile.log ---8<---8<---
[link_node_modules.js] An error has been reported: [Error: ENOENT: no such file or directory, unlink 'node_modules'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'unlink',
  path: 'node_modules'
} Error: ENOENT: no such file or directory, unlink 'node_modules'
---8<---8<--- End of log ---8<---8<---
INFO: Elapsed time: 12.796s, Critical Path: 5.39s
INFO: 645 processes: 477 internal, 12 darwin-sandbox, 156 worker.
```

PR Close #45393
2022-03-24 10:52:13 -07:00
Mike cc90fd55b2 docs(router): Fix typo on segments (#45411)
PR Close #45411
2022-03-24 10:49:36 -07:00
JoostK 3714305f84 fix(compiler): scope css rules within @layer blocks (#45396)
This commit starts scoping CSS rules nested within `@layer` blocks.

Fixes #45389

PR Close #45396
2022-03-21 14:51:46 -07:00
Amer Yousuf 7ff4c0bf39 fix(forms): improve error message for invalid value accessors (#45192)
improve error message for invalid value accessors when accessor is not provided as array

PR Close #45192
2022-03-15 13:26:04 -07:00
Renovate Bot 956b022254 build: lock file maintenance (#45298)
Refreshes the lock file through Renovate.

PR Close #45298
2022-03-14 09:29:12 -07:00
Jessica Janiuk b839aeb2c1 refactor(core): Switch over to new closure LOCALE vs getLocale() (#45302)
This is a change requested via an LSC due to a deprecation.

PR Close #45302
2022-03-10 12:48:30 -08:00
Kristiyan Kostadinov 895c5417e3 Set up 13.3.0 release for TypeScript 4.6 support (#45319)
* feat(core): support TypeScript 4.6 (#45190)

Adds support for TypeScript 4.6.

PR Close #45190

* build: update version to 13.3.0

Bumps up the version to 13.3.0-next.0 so the tooling can pick it up.
2022-03-10 10:33:21 -08:00
Andrew Scott 6336b8e5b3 refactor(router): Make a few adjustments to createUrlTree for clarity (#45306)
* `tree` function now accepts the old root rather than the old
  `UrlTree`. The `urlTree` argument was only used to get the `root`.
  This change makes it more clear what that pararmeter is used for and
  what's actually being used
* Move the `oldRoot` (previously `urlTree`) to be the first argument of `tree`.
  This change now mirrors the argument order for `replaceSegment` and
  can be read from left to right more easily "in this root,
  replace this old segment group with this new segment group".
* Extract `newRoot` to a variable. This just makes it more clear what's
  going on at the end rather than combining a bunch of operations into
  one.

These changes are being made so that hopefully a future refactor can be
done which does not rely on the `urlTree` argument at all in the
`createUrlTree` function. These refactorings will make it easier to see
1:1 functionlity in these various places.

PR Close #45306
2022-03-09 13:52:38 -08:00
Andrew Scott 9bce9ce89e fix(language-service): Prioritize Angular-specific completions over DOM completions (#45293)
When authoring Angular templates, developers are likely to be most interested in
the current Directive/Component inputs and outputs, then potential
attributes which would match other directives to the element,
and lastly the plethora of DOM events and attributes.

This change ensures that Angular-specific information appears above DOM
information by prepending the first printable ASCII characters to the
sort text.

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

PR Close #45293
2022-03-08 14:48:38 -08:00
Andrew Scott 8227eb914e refactor(migrations): update isReferenceToImport to not use valueDeclaration (#45292)
valueDeclaration is only set when the Symbol type is a `Value`:

* [setValueDeclaration](https://sourcegraph.com/github.com/microsoft/TypeScript@d8b21a8d6cef772fea5cf2a507b651c5d38194bd/-/blob/src/compiler/binder.ts?L321-322)
* [Value union](https://sourcegraph.com/github.com/microsoft/TypeScript@d8b21a8d6cef772fea5cf2a507b651c5d38194bd/-/blob/src/compiler/types.ts?L4849:9#tab=references)

This won't be the case if the symbol is an interface (notice that `Interface` is not in the union for `Value` above).

For this reason, we can't rely on the `valueDeclaration` property of the symbol.
Instead, it's more reliable to just compare the first items in the `declarations` list.

PR Close #45292
2022-03-08 13:13:26 -08:00
Luca cff1c5622f fix(service-worker): file system hash in batch of 500 elements (#45262)
Add file system concurrency hash test

Fixes #45133
PR Close #45262
2022-03-08 10:23:39 -08:00
Andrew Scott 6efa366e2c fix(compiler): compute correct offsets when interpolations have HTML entities (#44811)
When parsing interpolations, the input string is _decoded_ from what was
in the orginal template. This means that we cannot soley rely on the input
string to compute source spans because it does not necessarily reflect
the exact content of the original template. Specifically, when there is
an HTML entity (i.e. `&nbsp;`), this will show up in its decoded form
when processing the interpolation (' '). We need to compute offsets
using the original _encoded_ string.

Note that this problem only surfaces in the splitting of interpolations.
The spans to this point have already been tracked accurately. For
example, given the template `&nbsp;<div></div>`, the source span for the
`div` is already correctly determined to be 6. Only when we encounter
interpolations with many parts do we run into situations where we need
to compute new spans for the individual parts of the interpolation.

PR Close #44811
2022-03-08 10:23:08 -08:00
nanda18 8390e12bdd docs: update flush description to include microtasks (#45237)
PR Close #45237
2022-03-07 15:41:08 -08:00
Renovate Bot 43bbaf810d build: update dependency google-closure-compiler to v20220301 (#45260)
PR Close #45260
2022-03-07 14:30:47 -08:00
Renovate Bot 6842bf0515 build: update dependency magic-string to v0.26.1 (#45247)
PR Close #45247
2022-03-07 14:29:46 -08:00