18925 Commits

Author SHA1 Message Date
atscott
5db7b4c354 release: cut the v10.1.6 release 10.1.6 2020-10-14 13:33:19 -07:00
Pete Bacon Darwin
e08d02145e fix(ngcc): ensure that "inline exports" can be interpreted correctly (#39272)
Previously, inline exports of the form `exports.foo = <implementation>;` were
being interpreted (by the ngtsc `PartialInterpeter`) as `Reference` objects.
This is not what is desired since it prevents the value of the export
from being unpacked, such as when analyzing `NgModule` declarations:

```
exports.directives = [Directive1, Directive2];

@NgImport({declarations: [exports.directives]})
class AppModule {}
```

In this example the interpreter would think that `exports.directives`
was a reference rather than an array that needs to be unpacked.

This bug was picked up by the ngcc-validation repository. See
https://github.com/angular/ngcc-validation/pull/1990 and
https://circleci.com/gh/angular/ngcc-validation/17130

PR Close #39272
2020-10-14 12:59:07 -07:00
Pete Bacon Darwin
dae3a77c43 refactor(compiler-cli): visit inline declarations with implementations differently (#39272)
Some inline declarations are of the form:

```
exports.<name> = <implementation>;
```

In this case the declaration `node` is `exports.<name>`.
When interpreting such inline declarations we actually want
to visit the `implementation` expression rather than visiting
the declaration `node`.

This commit adds `implementation?: ts.Expression` to the
`InlineDeclaration` type and updates the interpreter to visit
these expressions as described above.

PR Close #39272
2020-10-14 12:59:07 -07:00
Pete Bacon Darwin
02e75df3e7 refactor(compiler-cli): ensure isNamed....() helpers check name is identity (#38959) (#39272)
Previously the `node.name` property was only checked to ensure it was
defined. But that meant that it was a `ts.BindingName`, which also includes
`ts.BindingPattern`, which we do not support. But these helper methods were
forcefully casting the value to `ts.Identifier.

Now we also check that the `node.name` is actually an `ts.Identifier`.

PR Close #38959

PR Close #39272
2020-10-14 12:59:07 -07:00
Pete Bacon Darwin
f752ab9367 fix(compiler-cli): support namespaced query types in directives (#38959) (#39272)
Previously directive "queries" that relied upon a namespaced type

```ts
queries: {
  'mcontent': new core.ContentChild('test2'),
}
```

caused an error to be thrown. This is now supported.

PR Close #38959

PR Close #39272
2020-10-14 12:59:07 -07:00
Pete Bacon Darwin
9c875b30dc fix(ngcc): support inline export declarations in UMD files (#38959) (#39272)
Previously, any declarations that were defined "inline" were not
recognised by the `UmdReflectionHost`.

For example, the following syntax was completely unrecognized:

```ts
var Foo_1;
exports.Foo = Foo_1 = (function() {
  function Foo() {}
  return Foo;
})();
exports.Foo = Foo_1 = __decorate(SomeDecorator, Foo);
```

Such inline classes were ignored and not processed by ngcc.

This lack of processing led to failures in Ivy applications that relied
on UMD formats of libraries such as `syncfusion/ej2-angular-ui-components`.

Now all known inline UMD exports are recognized and processed accordingly.

Fixes #38947

PR Close #38959

PR Close #39272
2020-10-14 12:59:07 -07:00
Pete Bacon Darwin
8fa78d10ab test(ngcc): use isNamedDeclaration() helper to simplify tests (#38959) (#39272)
Previously these tests were checking multiple specific expression
types. The new helper function is more general and will also support
`PropertyAccessExpression` nodes for `InlineDeclaration` types.

PR Close #38959

PR Close #39272
2020-10-14 12:59:07 -07:00
Pete Bacon Darwin
26988f0d62 refactor(compiler-cli): implement DeclarationNode node type (#38959) (#39272)
Previously the `ConcreteDeclaration` and `InlineDeclaration` had
different properties for the underlying node type. And the `InlineDeclaration`
did not store a value that represented its declaration.

It turns out that a natural declaration node for an inline type is the
expression. For example in UMD/CommonJS this would be the `exports.<name>`
property access node.

So this expression is now used for the `node` of `InlineDeclaration` types
and the `expression` property is dropped.

To support this the codebase has been refactored to use a new `DeclarationNode`
type which is a union of `ts.Declaration|ts.Expression` instead of `ts.Declaration`
throughout.

PR Close #38959

PR Close #39272
2020-10-14 12:59:06 -07:00
Pete Bacon Darwin
6acf117386 test(ngcc): use isNamedFunctionDeclaration() in UMD tests (#38959) (#39272)
This makes these tests more resilient to changes in the test code
structure. For example switching from

```
var SomeClass = <implementation>;
exports.SomeClass = SomeClass;
```

to

```
exports.SomeClass = <implementation>;
```

PR Close #38959

PR Close #39272
2020-10-14 12:59:06 -07:00
Pete Bacon Darwin
8b731e374d test(compiler-cli): make the getDeclaration() utility more resilient to code format (#38959) (#39272)
Previously `getDeclaration()` would only return the first node that matched
the name passed in and then assert the predicate on this single node.
It also only considered a subset of possible declaration types that we might
care about.

Now the function will parse the whole tree collecting an array of all the
nodes that match the name. It then filters this array based on the predicate
and only errors if the filtered array is empty.

This makes this function much more resilient to more esoteric code formats
such as UMD.

PR Close #38959

PR Close #39272
2020-10-14 12:59:06 -07:00
Pete Bacon Darwin
5378f78e79 refactor(ngcc): simplify and break up ES2015 functions with helpers (#38959) (#39272)
The protected helper functions can then be overridden by subclasses of the
Esm2015ReflectionHost.

PR Close #38959

PR Close #39272
2020-10-14 12:59:06 -07:00
Pete Bacon Darwin
495c40e31c refactor(ngcc): simplify and rename getClassDeclarationFromInnerDeclaration() (#38959) (#39272)
The new function does not try to restrict the kind of AST node that it
finds, leaving that to the caller. This will make it more resuable in the
UMD reflection host.

PR Close #38959

PR Close #39272
2020-10-14 12:59:06 -07:00
Pete Bacon Darwin
9963c5d8f7 fix(ngcc): handle aliases in UMD export declarations (#38959) (#39272)
Sometimes UMD exports appear in the following form:

```
exports.MyClass = alias1 = alias2 = <<declaration>>
```

Previously the declaration of the export would have been captured
as `alias1 = alias2 = <<declaration>>`, which the `PartialInterpreter`
would have failed on, since it cannot handle assignments.

Now we skip over these aliases capturing only the `<<declaration>>`
expression.

Fixes #38947

PR Close #38959

PR Close #39272
2020-10-14 12:59:06 -07:00
Pete Bacon Darwin
13c4a7b1da fix(ngcc): map exports to the current module in UMD files (#38959) (#39272)
UMD files export values by assigning them to an `exports` variable.
When evaluating expressions ngcc was failing to cope with expressions
like `exports.MyComponent`.

This commit fixes the `UmdReflectionHost.getDeclarationOfIdentifier()`
method to map the `exports` variable to the current source file.

PR Close #38959

PR Close #39272
2020-10-14 12:59:06 -07:00
Pete Bacon Darwin
70e85d226c test(ngcc): fix incorrect test setup (#38959) (#39272)
The `SIMPLE_CLASS_FILE` contained a `ChildClass` that had an
internal aliases implementation and extended a `SuperClass` base
class. The call to `__extends` was using the wrong argument for
the child class.

PR Close #38959

PR Close #39272
2020-10-14 12:59:06 -07:00
Pete Bacon Darwin
dfb129dbfa refactor(compiler-cli): move map creation to avoid unnecessary work (#38959) (#39272)
If the `symbol` for the given `node` does not exist then there is no
point in creating the `map`.

PR Close #38959

PR Close #39272
2020-10-14 12:59:06 -07:00
Pete Bacon Darwin
1a1407aef6 refactor(ngcc): rename ExportStatement to ExportsStatement (#38959) (#39272)
This clarifies that this is specifically about statements of the form
`exports.<name> = <declaration>`, rather than a general export
statement such as `export class <ClassName> { ... }`.

PR Close #38959

PR Close #39272
2020-10-14 12:59:05 -07:00
Pete Bacon Darwin
da71f76a6a refactor(ngcc): remove unused imports (#38959) (#39272)
The `isAssignment` and `isAssignmentStatement` are not used in this file.

PR Close #38959

PR Close #39272
2020-10-14 12:59:05 -07:00
Pete Bacon Darwin
0c9b76e9e7 refactor(compiler-cli): remove unnecessary constraint on isDeclarationReference() (#38959) (#39272)
There is no need to check that the `ref.node` is of any particular type
because immediately after this check the entry is tested to see if it passes
`isClassDeclarationReference()`.

The only difference is that the error that is reported is slightly different
in the case that it is a `ref` but not one of the TS node types.

Previously:

```
`Value at position ${idx} in the NgModule.${arrayName} of ${
                className} is not a reference`
```

now

```
`Value at position ${idx} in the NgModule.${arrayName} of ${
                  className} is not a class`
```

Arguably the previous message was wrong, since this entry IS a reference
but is not a class.

PR Close #38959

PR Close #39272
2020-10-14 12:59:05 -07:00
Pete Bacon Darwin
db34b23ab5 test(compiler-cli): improve error message if a unit test is bad (#38959) (#39272)
The message now also reports the name of the predicate function
that failed.

PR Close #38959

PR Close #39272
2020-10-14 12:59:05 -07:00
Alex Okrushko
df0941554b docs: add Discord as an official communication channel (#39149)
PR Close #39149
2020-10-14 10:23:16 -07:00
JoostK
5221df8e92 perf(ngcc): do not rescan program source files when referenced from multiple root files (#39254)
When ngcc is configured to run with the `--use-program-dependencies`
flag, as is the case in the CLI's asynchronous processing, it will scan
all source files in the program, starting from the program's root files
as configured in the tsconfig. Each individual root file could
potentially rescan files that had already been scanned for an earlier
root file, causing a severe performance penalty if the number of root
files is large. This would be the case if glob patterns are used in the
"include" specification of a tsconfig file.

This commit avoids the performance penalty by keeping track of the files
that have been scanned across all root files, such that no source file
is scanned multiple times.

Fixes #39240

PR Close #39254
2020-10-14 09:34:11 -07:00
atscott
bc35c6a8ed refactor(dev-infra): Adjust caretaker queries (#39257)
- The current initial triage does not include PRs. This includes them by removing the issue filter
- The merge assistance label is often applied to PRs that do not have
status=success. Caretaker should handle these as well

PR Close #39257
2020-10-14 09:07:05 -07:00
sajeetharan
23fc2b43ac updated sajee's profile (#39019)
PR Close #39019
2020-10-13 14:59:04 -07:00
d0rian
c16995eb59 docs: fix typo in the Reactive Forms guide #5 (#39245)
PR Close #39245
2020-10-13 13:38:29 -07:00
David Shevitz
3487d5a13a docs: move Inputs and Outputs topic to Components section (#38984)
PR Close #38984
2020-10-12 12:40:50 -07:00
George Kalpakas
1efc75cd72 fix(dev-infra): detect all commit message keywords that can close a PR (#39229)
Previously, the `isCommitClosingPullRequest()` method (used in
`ng-dev release` to detect whether a commit is closing a PR based on
keywords found in the commit message) was only able to detect a subset
of the keywords supported by GitHub.

This is fine currently, because the merge script adds `PR Close #XYZ`
when merging a PR, but it might break in the future.

This commit makes the code more robust by ensuring the method can detect
all keywords supported by GitHub for automatically closing a PR based on
a commit message.

Original discussion:
https://github.com/angular/angular/pull/39135#discussion_r503440973

PR Close #39229
2020-10-12 12:02:49 -07:00
George Kalpakas
c4190e3142 fix(dev-infra): fix error message in invokeSetNpmDistCommand() function (#39229)
In #39135, the commit message string was accidentally changed from a
template literal to a regular string literal. This prevented the
`npmDistTag` variable from being correctly displayed in the error
message.

This commit fixes it by switching it back to a template literal.

NOTE:
This was pointed out in
https://github.com/angular/angular/pull/39135#discussion_r503361412, but
the PR was accidentally merged before the review feedback had been
addressed.

PR Close #39229
2020-10-12 12:02:49 -07:00
George Kalpakas
5d98834585 fix(dev-infra): correctly check for commit that closes PR (#39135)
The `ng-dev release publish` command needs to check whether a commit
closed a pull request. This is implemented via checking the commit
message for specific closing keywords referencing the pull request
number.

The regex used previously failed to correctly ensure that the specified
pull request was referenced. For example, it would allow `#12345` to
also match for `#1234`.

This commit fixes the regex.

PR Close #39135
2020-10-12 10:47:14 -07:00
George Kalpakas
529ff73200 refactor(dev-infra): several code style and typo fixes (#39135)
This commit addresses comments from [my review][1] on PR #38656 (which
was merged without comments addressed). The changes are mostly related
to code style and typos.

[1]: https://github.com/angular/angular/pull/38656#pullrequestreview-482129333

PR Close #39135
2020-10-12 10:47:14 -07:00
Taymon A. Beal
791205005c refactor(animations): do not assign to innerHTML (#37397)
This should not change behavior, but it prevents false-positive warnings in various static analysis
tools, including tools used internally at Google.

PR Close #37397
2020-10-12 10:45:00 -07:00
George Kalpakas
2d37e47e95 build(docs-infra): support passing args to ng serve via serve-and-sync (#39201)
When working on the docs, it is helpful to run a local instance of the
angular.io app and run scripts that watch both the docs contents and the
app build artifacts to automatically update the running instance on
changes. Typically, this is achieved via the `start` and `docs-watch`
npm scripts. As a convenience, one can run the `serve-and-sync` script,
which runs both in one terminal.

Previously, it was not possible to pass arguments to `ng nerve` (which
is what the `start` script runs under the hood) when running it via
`serve-and-sync`.

This commit adds support for passing any arguments passed to
`serve-and-sync` through to the `start` script. This can be useful for
things like specifying a custom host or port.

PR Close #39201
2020-10-12 08:27:01 -07:00
George Kalpakas
27c8066641 docs: add linkable section about updating commit messages in CONTRIBUTING.md (#39215)
A common review request is updating the commit message of a commit.
Since this is something that is not straight forward for inexperienced
contributors, it is useful to be able to point a contributor to some
docs outlining the process.

This commit adds such a section in `CONTRIBUTING.md` (as discussed in
https://github.com/angular/angular/pull/39110#discussion_r499935502).

PR Close #39215
2020-10-12 08:26:09 -07:00
Adam Plumer
952fd8662c fix(elements): detect matchesSelector prototype without IIFE (#37799)
Although in SSR we patch the global prototypes with DOM globals
like Element and Node, this patch does not occur before the
matches function is called in Angular Elements. This is similar
to the behavior in @angular/upgrade.

Fixes #24551

PR Close #37799
2020-10-09 10:02:25 -07:00
Andrew Scott
42be9047d8 feat(dev-infra): Add github links to caretaker checks (#39185)
This commit adds links to the PR/Issue for queries in the caretaker check.

PR Close #39185
2020-10-09 09:39:33 -07:00
crisbeto
52a0c6b36e fix(compiler): incorrectly encapsulating @import containing colons and semicolons (#38716)
At a high level, the current shadow DOM shim logic works by escaping the content of a CSS rule
(e.g. `div {color: red;}` becomes `div {%BLOCK%}`), using a regex to parse out things like the
selector and the rule body, and then re-adding the content after the selector has been modified.
The problem is that the regex has to be very broad in order capture all of the different use cases,
which can cause it to match strings suffixed with a semi-colon in some places where it shouldn't,
like this URL from Google Fonts `https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&display=swap`.
Most of the time this is fine, because the logic that escapes the rule content to `%BLOCK%` will
have converted it to something that won't be matched by the regex. However, it breaks down for rules
like `@import` which don't have a body, but can still have quoted content with characters that can
match the regex.

These changes resolve the issue by making a second pass over the escaped string and replacing all
of the remaining quoted content with `%QUOTED%` before parsing it with the regex. Once everything
has been processed, we make a final pass where we restore the quoted content.

In a previous iteration of this PR, I went with a shorter approach which narrowed down the
regex so that it doesn't capture rules without a body. It fixed the issue, but it also ended
up breaking some of the more contrived unit test cases. I decided not to pursue it further, because
we would've ended up with a very long and brittle regex that likely would've broken in even weirder
ways.

Fixes #38587.

PR Close #38716
2020-10-09 08:33:05 -07:00
Bjarki
8913aee527 build: bump Chromium to next stable version: 84.0.4147 (#39179)
Bump Chrome to the next stable release (84.0.4147) by following the
instructions in dev-infra/browsers/README.md.

With Chrome 86 about to be released as stable, the current local version
(Chrome 83) is starting to lag behind. It also contains a bug that
blocks Angular unit and integration tests from using Trusted Types.

PR Close #39179
2020-10-09 07:53:12 -07:00
Greg Magolan
7628c36f49 build: upgrade angular build, integration/bazel and @angular/bazel package to rule_nodejs 2.2.0 (#39182)
Updates to rules_nodejs 2.2.0. This is the first major release in 7 months and includes a number of features as well
as breaking changes.

Release notes: https://github.com/bazelbuild/rules_nodejs/releases/tag/2.0.0

Features of note for angular/angular:

* stdout/stderr/exit code capture; this could be potentially be useful

* TypeScript (ts_project); a simpler tsc rule that ts_library that can be used in the repo where ts_library is too
  heavy weight

Breaking changes of note for angular/angular:

* loading custom rules from npm packages: `ts_library` is no longer loaded from `@npm_bazel_typescript//:index.bzl`
  (which no longer exists) but is now loaded from `@npm//@bazel/typescript:index.bzl`

* with the loading changes above, `load("@npm//:install_bazel_dependencies.bzl", "install_bazel_dependencies")` is
  no longer needed in the WORKSPACE which also means that yarn_install does not need to run unless building/testing
  a target that depends on @npm. In angular/angular this is a minor improvement as almost everything depends on @npm.

* @angular/bazel package is also updated in this PR to support the new load location; Angular + Bazel users that
  require it for ng_package (ng_module is no longer needed in OSS with Angular 10) will need to load from
  `@npm//@angular/bazel:index.bzl`. I investigated if it was possible to maintain backward compatability for the old
  load location `@npm_angular_bazel` but it is not since the package itself needs to be updated to load from
  `@npm//@bazel/typescript:index.bzl` instead of `@npm_bazel_typescript//:index.bzl` as it depends on ts_library
  internals for ng_module.

* runfiles.resolve will now throw instead of returning undefined to match behavior of node require

Other changes in angular/angular:

* integration/bazel has been updated to use both ng_module and ts_libary with use_angular_plugin=true.
  The latter is the recommended way for rules_nodejs users to compile Angular 10 with Ivy. Bazel + Angular ViewEngine is
  supported with @angular/bazel <= 9.0.5 and Angular <= 8. There is still Angular ViewEngine example on rules_nodejs
  https://github.com/bazelbuild/rules_nodejs/tree/stable/examples/angular_view_engine on these older versions but users
  that want to update to Angular 10 and are on Bazel must switch to Ivy and at that point ts_library with
  use_angular_plugin=true is more performant that ng_module. Angular example in rules_nodejs is configured this way
  as well: https://github.com/bazelbuild/rules_nodejs/tree/stable/examples/angular. As an aside, we also have an
  example of building Angular 10 with architect() rule directly instead of using ts_library with angular plugin:
  https://github.com/bazelbuild/rules_nodejs/tree/stable/examples/angular_bazel_architect.

NB: ng_module is still required for angular/angular repository as it still builds ViewEngine & @angular/bazel
also provides the ng_package rule. ng_module can be removed in the future if ViewEngine is no longer needed in
angular repo.

* JSModuleInfo provider added to ng_module. this is for forward compat for future rules_nodejs versions.

PR Close #39182
2020-10-08 11:55:00 -07:00
Chellappan
b417dd7b9c docs: fix for HttpRequest expansion panel (#39166)
Fixes #39156

PR Close #39166
2020-10-08 09:38:10 -07:00
Alan Agius
8cf16b4815 feat(docs-infra): add short url for strict mode guide (#39129)
With this change we add a short url to strict mode guide
(angular.io/strict -> angular.io/guide/strict-mode). This is important because
of two reasons.

1) Reduce the clutter in the terminal when we include the strict mode guide url in a prompt.
2) Easiler to share in conferences, slides etc..

PR Close #39129
2020-10-08 08:45:03 -07:00
Joey Perrott
806aed63f4 test(compiler-cli): temporarily disable integrationtest (#39168)
Temporarily disable the //packages/compiler-cli/integrationtest:integrationtest
target while continuing to investigate its unknown failures

PR Close #39168
2020-10-08 08:43:49 -07:00
atscott
eb34037cd7 Revert "refactor(compiler-cli): wrap RHS of property write in parens (#39143)" (#39171)
This reverts commit ba0df5250f667c337b61ef7415d178ef27024207.
Causes CI failures

PR Close #39171
2020-10-07 16:09:07 -07:00
Andrew Scott
ba0df5250f refactor(compiler-cli): wrap RHS of property write in parens (#39143)
The right needs to be wrapped in parens or we cannot accurately match its
span to just the RHS. For example, the span in `e = $event /*0,10*/` is ambiguous.
It could refer to either the whole binary expression or just the RHS.
We should instead generate `e = ($event /*0,10*/)` so we know the span 0,10 matches RHS.
This is specifically needed for the TemplateTypeChecker/Language Service
when mapping template positions to items in the TCB.

PR Close #39143
2020-10-07 14:49:47 -07:00
Joey Perrott
c4553bbed9 release: cut the v10.1.5 release 10.1.5 2020-10-07 14:20:12 -07:00
Pete Bacon Darwin
cc13b37446 build(docs-infra): render optional decorator options with a ? (#39167)
Decorator API pages list all their available options in an overview
table and also in a detailed view. Now the rendered syntax of each
option will show a `?` after the name if the option is not required.
This is inline with how class and interface members are rendered.

PR Close #39167
2020-10-07 13:33:26 -07:00
Kizashi Nagata
166df5d2ca refactor(common): remove i (ignore case) regex flag where it is not needed (#39077)
It is not necessary to set IGNORECASE flag when the regex pattern does
not contain alphabetic characters

PR Close #39077
2020-10-07 13:32:00 -07:00
Sonu Kapoor
a5b474580c docs: change heading to a sub-heading (#39131)
This commit changes the heading of the section
`Use TypeScript path mapping for peer dependencies` to a sub-heading of
`Linked Libraries`.

Fixes #39130

PR Close #39131
2020-10-07 13:31:24 -07:00
Nihal
9f132d0d93 docs: remove explicit boolean type in examples as TS infers it automatically (#39081)
In the `packages/examples/common/ngif/module.ts` file, the field `show` is given an explicit
boolean type. Since typescript infers boolean type, it is redundant and this commit removes it.

PR Close #39081
2020-10-06 08:39:02 -07:00
George Kalpakas
8dee378b3e docs: add info about working with fixup commits (#39110)
Using fixup commits when addressing review feedback can considerably
improve the review experience on subsequent reviews.

This commit adds information and guidelines for contributors on how to
work with fixup commits.

Fixes #33042

PR Close #39110
2020-10-06 08:38:35 -07:00
Joey Perrott
0845d1148f build: update bazelversion (#39123)
Updates to the latest version of bazel

PR Close #39123
2020-10-05 17:08:08 -07:00