Commit Graph

21174 Commits

Author SHA1 Message Date
Jessica Janiuk 00b1444d12 Revert "feat(forms): add `ng-submitted` class to forms that have been submitted." (#42474)
This reverts commit f024d7556081f8913f21761bb8e6aab8d08be110.

PR Close #42474
2021-06-03 17:42:02 -07:00
Joey Perrott ae858c0504 ci: extend default timeout of karma tests for legacy saucelab tests (#42473)
After testing, it seems that the flakyness we are experiencing in our legacy
saucelabs job is caused by timeouts which happen due to the karma server being
unable to serve all of the files needed for the tests fast enough while concurrent
tests are being run.

PR Close #42473
2021-06-03 16:06:00 -07:00
Paul Gschwendtner 1684b70b88 test(dev-infra): always use same virtual git client instance in publish tests (#42468)
With the recent refactorings to `GitClient`, where singletons
are created and can be retrieved through a static method, the
test has been updated to also install spies for the static methods
of `GitClient`. This commit updates the spy installation so that
the same mock git client is used that is also passed manually to
the release actions. Having two separate instances of the mock
git client could result in false-positive test results.

PR Close #42468
2021-06-03 14:34:33 -07:00
Paul Gschwendtner 67f65a9d25 refactor(dev-infra): improve type-safety of git client utility (#42468)
Currently the `GitClient` accepts a generic parameter for determining
whether the `githubToken` should be set or not. This worked fine so far
in terms of distinguishing between an authenticated and
non-authenticated git client instance, but if we intend to conditionally
show methods only for authenticated instances, the generic parameter
is not suitable.

This commit splits up the `GitClient` into two classes. One for
the base logic without any authorization, and a second class that
extends the base logic with authentication logic. i.e. the
`AuthenticatedGitClient`. This allows us to have specific methods only
for the authenticated instance. e.g.

  * `hasOauthScopes` has been moved to only exist for authenticated
    instances.
  * the GraphQL functionality within `gitClient.github` is not
    accessible for non-authenticated instances. GraphQL API requires
    authentication as per Github.

The initial motiviation for this was that we want to throw if
`hasOAuthScopes` is called without the Octokit instance having
a token configured. This should help avoiding issues as within
3b434ed94d
that prevented the caretaker process momentarily.

Additionally, the Git client has moved from `index.ts` to
`git-client.ts` for better discoverability in the codebase.

PR Close #42468
2021-06-03 14:34:33 -07:00
David Shevitz aea56048f6 docs: update host and viewproviders section with correct logical tree representation (#42403)
Fixes #38741

PR Close #42403
2021-06-03 14:33:44 -07:00
George Kalpakas 268e0040e7 build(docs-infra): disable critical CSS inlining (#42435)
Previously, the critical CSS inlining optimization (which is turned on
by default in CLI v12+) was causing a Flash Of Unstyled Content (FOUC).
This was caused by the combination of the following facts:
- The way CSS inlining is implemented in the CLI makes loading the full
  styles asynchronous and non-render-blocking (so the app can bootstrap
  before the styles are fully downloaded).
- Angular.io does not employ the [app shell][1] pattern in order to
  render pages at build time, resulting in very minimal CSS rules being
  recognized as critical (for the purpose of inlining).

This commit fixes the FOUC by disabling the critical CSS inlining, while
we consider a better way to approach this (in order to be able to rip
the benefits of inlining without the FOUC).

[1]: https://angular.io/guide/app-shell

Fixes #42365

PR Close #42435
2021-06-03 14:32:06 -07:00
Kristiyan Kostadinov ba084857ea feat(compiler): support safe keyed read expressions (#41911)
Currently we support safe property (`a?.b`) and method (`a?.b()`) accesses, but we don't handle safe keyed reads (`a?.[0]`) which is inconsistent. These changes expand the compiler in order to support safe key read expressions as well.

PR Close #41911
2021-06-03 13:22:41 -07:00
Dylan Hunn 47270d9e63 feat(forms): add `ng-submitted` class to forms that have been submitted. (#42132)
As previously discussed in pull/31070 and issues/30486, this would be useful because it is often desirable to apply styles to fields that are both `ng-invalid` and `ng-pristine` after the first attempt at form submission, but Angular does not provide any simple way to do this (although evidently Angularjs did). This will now be possible with a descendant selector such as `.ng-submitted .ng-invalid`.

In this implementation, the directive that sets control status classes on forms and formGroups has its set of statuses widened to include `ng-submitted`. Then, in the event that `is('submitted')` is invoked, the `submitted` property of the control container is returned iff it exists. This is preferred over checking whether the container is a `Form` or `FormGroup` directly to avoid reflecting on those classes.

Closes #30486.

PR Close #42132
2021-06-03 13:21:29 -07:00
Paul Gschwendtner fa84d19e97 refactor(dev-infra): always use en-US locale for printing date in merge tool (#42470)
In the dev-infra merge tool, a test fails locally if it runs on
a system with a different system locale. We can either make the
test more flexible, or update the merge tool to always print the date
in `en-US` format. The latter is more reasonable given our console
messages being in english anyway.

PR Close #42470
2021-06-03 13:19:03 -07:00
cindygk c8e4783d14 docs: offboard misko and annie from contributors page (#42467)
PR Close #42467
2021-06-03 13:17:45 -07:00
JoostK 69e57827e2 refactor(compiler-cli): remove unused return type transform (#41996)
With the removal of the `ModuleWithProviders` transform in the parent commit,
the underlying dts transform can also be removed as it is not used elsewhere.

PR Close #41996
2021-06-03 11:38:58 -07:00
JoostK ce8720910d refactor(compiler-cli): remove `ModuleWithProviders` generic type transform (#41996)
The `ModuleWithProviders` type has required a generic type since Angular 10,
so it is no longer necessary for the compiler to transform usages of the
`ModuleWithProviders` type without the generic type, as that should have
been reported as a compile error. This commit removes the detection logic
from ngtsc.

PR Close #41996
2021-06-03 11:38:58 -07:00
iRealNirmal 751cd83ae3 fix(forms): the `min` and `max` validators should work correctly with `0` as a value (#42412)
Prior to this change the `min` and `max` validator directives would not
set the `min` and `max` attributes on the host element. The problem was
caused by the truthy check in host binding expression that was
calculated as `false` when `0` is used as a value. This commit updates
the logic to leverage nullish coalescing operator in these host binding
expressions, so `0` is treated as a valid value, thus the `min` and
`max` attributes are set correctly.

Partially closes #42267

PR Close #42412
2021-06-03 11:34:46 -07:00
JoostK 85c7f7691e fix(common): infer correct type when `trackBy` is used in `ngFor` (#41995)
When a `trackBy` function is used that accepts a supertype of the iterated
array's type, the loop variable would undesirably be inferred as the supertype
instead of the array's item type. This commit adds an inferred type parameter
to `TrackByFunction` to allow an extra degree of freedom, enabling the
loop value to be inferred as the most narrow type.

Fixes #40125

PR Close #41995
2021-06-03 11:33:26 -07:00
JoostK 9d290b4fef test(compiler-cli): move `TrackByFunction` from `fake_common` to `fake_core` (#41995)
The `TrackByFunction` is declared in `@angular/core` so it should also be
included in `fake_core` instead of `fake_common`.

PR Close #41995
2021-06-03 11:33:26 -07:00
JoostK 481540dd4e test(compiler-cli): load type declarations from fake_common (#41995)
The ngtsc test targets have fake declarations files for `@angular/core`
and `@angular/common` and the template type checking tests can leverage
the fake common declarations instead of declaring its own types.

PR Close #41995
2021-06-03 11:33:26 -07:00
JoostK bd1836b999 fix(compiler-cli): exclude type-only imports from cycle analysis (#42453)
Type-only imports are known to be elided by TypeScript, so the compiler
can be certain that such imports do not contribute to potential import
cycles. As such, type-only imports are no longer considered during cycle
analysis.

Regular import statements that would eventually be fully elided by
TypeScript during emit if none of the imported symbols are used in a
value position continue to be included in the cycle analysis, as the
cycle analyzer is unaware of these elision opportunities. Only explicit
`import type` statements are excluded.

PR Close #42453
2021-06-03 11:31:59 -07:00
Vahid Mohammadi 374fa2c26f fix(common): initialize currencyCode in currencyPipe (#40505)
currencyCode should be initialized with the injected default currency code

PR Close #40505
2021-06-03 10:52:28 -07:00
George Kalpakas c964ad66d4 test(docs-infra): fix URL for a11y testing of angular.io (#42462)
This commit fixes one of the URLs used for testing the accessibility of
angular.io from `start-routing` to `start/start-routing`. The old URL is
not correct and result in a "Page not found" error.

This commit also increases some of the a11y scores.

PR Close #42462
2021-06-03 10:50:29 -07:00
Renovate Bot f02382dfd4 build: update dependency lighthouse to v8 (#42462)
PR Close #42462
2021-06-03 10:50:29 -07:00
mgechev 65921eb61e ci: update the sha of the feature request process bot (#42469)
Use the latest version of the feature request process bot that
incorporates the latest fixes.

PR Close #42469
2021-06-03 10:43:47 -07:00
Renovate Bot 42449b4555 build: update all non-major dependencies (#42382)
PR Close #42382
2021-06-03 10:41:32 -07:00
Paul Gschwendtner 57865b352a ci: do not update shared dev-infra package in components-repo-unit-tests job (#42268)
The shared dev-infra package from `HEAD` should not be installed
when running the `components-repo-unit-tests` job. This is done
because otherwise changes to the dev-infra package can result in
build setup issues for the CI job (while the goal of the CI job
is to test the framework)

PR Close #42268
2021-06-03 10:37:41 -07:00
Paul Gschwendtner a16f82b851 refactor(dev-infra): move shared browser bazel setup into dedicated bazel folder (#42268)
This change moves the `dev-infra/browsers` folder into `dev-infra/bazel`.
The browser folder is providing custom configuration for Bazel, so it
should live within the `bazel` folder for a more well-structured
`dev-infra` folder.

PR Close #42268
2021-06-03 10:37:41 -07:00
Paul Gschwendtner 49c3ce58bf refactor(dev-infra): remove duplicate method that checks for uncommitted changes (#42409)
Removes the duplicate `hasLocalChanges` method from the Git client. We
already have `hasUncommittedChanges`. Also removes a TODO for adding
`assertNoLocalChanges` as it seems more flexible to manually check
(i.e. better messaging with context on the current tool; e.g. "cannot
perform rebase")

PR Close #42409
2021-06-03 10:36:40 -07:00
David Shevitz 71fa896a91 docs: update link to jasmine documentation about spies (#42463)
PR Close #42463
2021-06-03 10:34:23 -07:00
Kristiyan Kostadinov 3d1c905c91 refactor(docs-infra): clean up AIO Sass files (#42442)
Cleans up AIO's Sass files by:
* Switching them all over to the `@use`-based API from Angular Material.
* Removing the import of the Material theming API in a bunch of places that weren't using it.
* Migrating the new usages of Sass utility functions to the new syntax (e.g. `map.get` vs `map-get`).
* Fixing a few files that were using 4 spaces for indentation instead of 2.

PR Close #42442
2021-06-02 13:25:42 -07:00
Alex 0ac193c86c docs: fix typo in the Router guide (#42455)
PR Close #42455
2021-06-02 13:24:30 -07:00
Paul Gschwendtner 97c5a3ae6f feat(dev-infra): prevent deprecations from being merged into patch branch (#42454)
As per SemVer, deprecations should only be released if the
minor version is incremented. This means that we should error
if commits w/ deprecations target an upcoming patch, LTS release.

Additionally, we also error if deprecations are made as part of
an upcoming release-candidate.

PR Close #42454
2021-06-02 13:23:54 -07:00
Paul Gschwendtner 107f15df03 refactor(dev-infra): add JSDoc throws description to assertion functions (#42454)
Adds the JSDoc `@throws` annotation to functions that would throw
within in the ng-dev tool. We want to add `@throws` so clearly
communicate if the invocation of a function results in errors or not.

This helps if IDEs show the `@throws` annotation on invocation, or
if TS ever lands a feature like Java `throws`, with more fine-grained
and typed error handling.

PR Close #42454
2021-06-02 13:23:54 -07:00
Paul Gschwendtner d3531a7d41 fix(dev-infra): breaking change and deprecation notes incorrectly picked up (#42436)
If a commit message currently mentions the breaking change or
deprecation note keywords, the commit message parse logic
accidentally picks up the note. This could then accidentally
prevent the commit from being merged (e.g. if the commit targets
the patch branch but mentioned the `BREAKING CHANGE: ` marker).

This commit switches the commit message notes pattern to only
capture notes at the beginning of a line (also allowing accidental
whitespace). This matches with the format we describe in our
contribution guide, as well as with our commit message validation
logic that also assumes notes at the beginning of a line.

PR Close #42436
2021-06-02 13:22:55 -07:00
Paul Gschwendtner bc5a8f4d37 feat(dev-infra): validate deprecation notes in commit messages (#42436)
Currently the commit message validation tool from `ng-dev` validates
the `BREAKING CHANGE:` commit message notes. This commit adds a similar
check for `DEPRECATED:` commit message notes.

Additionally, the check for breaking changes is reworked slightly to
be more tolerant (i.e. if there is only a single line break after the
summary; this is acceptable as per the parser and commonly done in the
COMP repo). The checks have been updated to capture wrong keywords that
are commonly used instead of the correct one. e.g. if a commit message
uses `DEPRECATIONS:` instead of `DEPRECATED:`, the validation will fail.

This prevents changelog generation issues where breaking change notes,
or deprecations are missing. This happened in the COMP repo where
the `DEPRECATED:` keyword was used incorrectly. See:

99391e7939

PR Close #42436
2021-06-02 13:22:55 -07:00
Sam Severance c0b2eeb54c docs: remove unused imports from unit tests (#42441)
PR Close #42441
2021-06-02 13:22:09 -07:00
Sam Severance c1a9f07ea1 docs: refactor `WelcomeComponent` unit test (#42441)
PR Close #42441
2021-06-02 13:22:08 -07:00
Igor Minar 1fe1dd1f19 docs: clarify the wording around live examples for all testing guides (#42406)
We should primarily point readers to the stackblitz that contains the spec files and runs them.

The application stackblitz is secondary (and doesn't actually contain the spec files, which is confusing).

Fixes #38535

PR Close #42406
2021-06-02 13:20:13 -07:00
Igor Minar 4c39869566 docs: add a note about javascript mime-types to the deployment guide (#42339)
Some servers don't serve the .js files with the correnct headers. This change documents the requirement.

Fixes #30835

PR Close #42339
2021-06-02 13:17:36 -07:00
Renovate Bot f3f10140b5 build: lock file maintenance (#42264)
PR Close #42264
2021-06-02 13:16:58 -07:00
Andrew Scott fe22c2b0b6 fix(language-service): Correct rename info for pipe name expressions (#41974)
Prior to this PR, attempting to get rename info for pipe name expressions would defer to the
typescript language service, which would return no rename info. This was not caught because
the test was written incorrectly.

This PR corrects the test behavior and adjusts the logic in getting rename info to account
for indirect renames (like pipe names).

PR Close #41974
2021-06-02 13:15:48 -07:00
Paul Gschwendtner f8814d3558
fix(dev-infra): update outdated build-worker.js file (#42458)
Updates the outdated build-worker.js file. This file has
been accidentally not updated when we fixed the Octokit
authentication to unblock the caretaker.
2021-06-02 13:13:26 -07:00
Paul Gschwendtner 3b434ed94d
fix(dev-infra): github oauth token not picked up by Octokit (#42456)
We recently updated `@octokit/rest` to a more recent version. For this
the Github client had to be refactored to account for new types of
Octokit. With the refactorings the authentication of the Github
client broke as we used an incorrect option for setting the OAuth
token. The TS transpilation did not fail because the Octokit types
support arbitrary options in the constructor. This is not solvable
on our side, so we cannot prevent similar issues in the future
unfortunately. Adding tests for authentication is not a reasonable
option either.
2021-06-02 12:48:51 -07:00
Andrew Kushnir 7bd5ea4a7e release: cut the v12.1.0-next.4 release 2021-06-02 18:02:43 +00:00
Andrew Kushnir 678b264d0d docs: release notes for the v12.0.3 release 2021-06-02 17:55:27 +00:00
David Pfeiffer 574f64041e docs: specify correct interceptor class type (#42437)
In the "Interceptor order" section of the HTTP guide there is a typo which incorrectly lists the same service twice when referring to two different services. The order that these services are listed is important, and this commit fixes the typo by listing the services in the correct order.
PR Close #42437
2021-06-01 16:36:58 -07:00
Andrew Scott 6a2e3e2b2c docs: change Navigation from type to interface (#42281)
Navigation type should be interface so it can be documented on aio site.

fixes #37384

PR Close #42281
2021-06-01 14:13:20 -07:00
Renovate Bot 2b7dc15655 build: update dependency ts-node to v10 (#42257)
PR Close #42257
2021-06-01 14:12:37 -07:00
Renovate Bot 5babdb2284 build: update angular (#42379)
PR Close #42379
2021-06-01 12:51:54 -07:00
Alex Rickabaugh e039075a28 fix(compiler-cli): better detect classes that are indirectly exported (#42207)
The compiler flag `compileNonExportedClasses` allows the Angular compiler to
process classes which are not exported at the top level of a source file.
This is often used to allow for AOT compilation of test classes inside
`it()` test blocks, for example.

Previously, the compiler would identify exported classes by looking for an
`export` modifier on the class declaration itself. This works for the
trivial case, but fails for indirectly exported classes:

```typescript
// Component is declared unexported.
@Component({...})
class FooCmp {...}

// Indirect export of FooCmp
export {FooCmp};
```

This is not an immediate problem for most application builds, since the
default value for `compileNonExportedClasses` is `true` and therefore such
classes get compiled regardless.

However, in the Angular Language Service now, `compileNonExportedClasses` is
forcibly overridden to `false`. That's because the tsconfig used by the IDE
and Language Service is often far broader than the application build's
configuration, and pulls in test files that can contain unexported classes
not designed with AOT compilation in mind.

Therefore, the Language Service has trouble working with such structures.

In this commit, the `ReflectionHost` gains a new API for detecting whether a
class is exported. The implementation of this method now not only considers
the `export` modifier, but also scans the `ts.SourceFile` for indirect
exports like the example above. This ensures the above case will be
processed directly in the Language Service.

This new operation is cached using an expando symbol on the `ts.SourceFile`,
ensuring good performance even when scanning large source files with lots of
exports (e.g. a FESM file under `ngcc`).

Fixes #42184.

PR Close #42207
2021-06-01 12:16:46 -07:00
JoostK 44b737ecb4 docs: clarify how declaration files can be installed (#42417)
The documentation suggested that `@types/*` scoped packages would
automatically be recognized, however the CLI configures a project such
that the package has to be explicitly added to the TypeScript
configuration files.

Closes #37572

PR Close #42417
2021-06-01 10:17:32 -07:00
Kristiyan Kostadinov 3e192bfa4d build: fix linting against jasmine focus functions (#42415)
We were linting against usages of `fdescribe` and `fit` by referencing the `no-jasmine-focus` rule which isn't installed, causing tslint to log the following:

```
Could not find implementations for the following rules specified in the configuration:
    no-jasmine-focus
Try upgrading TSLint and/or ensuring that you have all necessary custom rules installed.
If TSLint was recently upgraded, you may have old rules configured which need to be cleaned
```

These changes switch to using the built-in `ban` rule.

PR Close #42415
2021-06-01 10:16:55 -07:00
George Kalpakas 1d9c6bb31d docs(docs-infra): document the implementation of styles (incl. theming) in angular.io (#42396)
PR Close #42396
2021-06-01 10:16:21 -07:00