Commit Graph

5589 Commits

Author SHA1 Message Date
George Kalpakas 2baf90209b refactor(ngcc): tighten method parameter type to avoid redundant check (#35527)
`Esm5ReflectionHost#getInnerFunctionDeclarationFromClassDeclaration()`
was already called with `ts.Declaration`, not `ts.Node`, so we can
tighten its parameter type and get rid of a redundant check.
`getIifeBody()` (called inside
`getInnerFunctionDeclarationFromClassDeclaration()`) will check whether
the given `ts.Declaration` is a `ts.VariableDeclaration`.

PR Close #35527
2020-02-20 15:12:07 -08:00
Andrew Kushnir 646655d09a fix(compiler): use FatalDiagnosticError to generate better error messages (#35244)
Prior to this commit, decorator handling logic in Ngtsc used `Error` to throw errors. This commit replaces most of these instances with `FatalDiagnosticError` class, which provider a better diagnostics error (including location of the problematic code).

PR Close #35244
2020-02-20 11:25:23 -08:00
Pete Bacon Darwin df75451a0c fix(localize): support minified ES5 `$localize` calls (#35562)
Some minification tooling modifies `$localize` calls
to contain a comma sequence of items, where the
cooked and raw values are assigned to variables.

This change improves our ability to recognize these
structures.

Fixes #35376

PR Close #35562
2020-02-20 10:55:53 -08:00
Kristiyan Kostadinov dc4ae4b4cf fix(animations): false positive when detecting Node in Webpack builds (#35134)
We have to do some extra work in the animations module when we identify a Node environment which we determine based on the `process` global. The problem is that by default Webpack will polyfill the `process`, causing us to incorrectly identify it. These changes make it so that the check isn't thrown off by Webpack.

Fixes #35117.

PR Close #35134
2020-02-20 10:51:15 -08:00
zhuyujie a756161dc2 fix(core): make subclass inherit developer-defined data (#35105)
PR Close #35105
2020-02-19 12:50:48 -08:00
Paul Gschwendtner 8e12707f88 build: remove dependency on `@types/chokidar` (#35371)
We recently updated chokidar to `3.0.0`. The latest version of
chokidar provides TypeScript types on its own and makes the extra
dependency on the `@types` unnecessary.

This seems to have caused the `build-packages-dist` script to fail with
an error like:

```
[strictDeps] transitive dependency on external/npm/node_modules/chokidar/types/index.d.ts
   not allowed. Please add the BUILD target to your rule's deps.
```

It's unclear why that happens, but a reasonable theory would be that
the TS compilation accidentally picked up the types from `chokidar`
instead of `@types/chokidar`, and the strict deps `@bazel/typescript`
check reported this as issue because it's not an explicit target dependency.

PR Close #35371
2020-02-19 12:49:52 -08:00
Pete Bacon Darwin eef07539a6 feat(ngcc): pause async ngcc processing if another process has the lockfile (#35131)
ngcc uses a lockfile to prevent two ngcc instances from executing at the
same time. Previously, if a lockfile was found the current process would
error and exit.

Now, when in async mode, the current process is able to wait for the previous
process to release the lockfile before continuing itself.

PR Close #35131
2020-02-18 17:20:41 -08:00
Pete Bacon Darwin 7e8ce24116 refactor(compiler-cli): add `invalidateCaches` to `CachedFileSystem` (#35131)
This is needed by ngcc when reading volatile files that may
be changed by an external process (e.g. the lockfile).

PR Close #35131
2020-02-18 17:20:41 -08:00
Andrew Kushnir f95b8ce07e fix(ivy): add attributes and classes to host elements based on selector (#34481)
In View Engine, host element of dynamically created component received attributes and classes extracted from component's selector. For example, if component selector is `[attr] .class`, the `attr` attribute and `.class` class will be add to host element. This commit adds similar logic to Ivy, to make sure this behavior is aligned with View Engine.

PR Close #34481
2020-02-18 17:18:13 -08:00
Pawel Kozlowski 3f4e02b8c7 fix(ivy): queries should match elements inside ng-container with the descendants: false option (#35384)
Before this change content queries with the `descendants: false` option, as implemented in ivy,
would not descendinto `<ng-container>` elements. This behaviour was different from the way the
View Engine worked. This change alligns ngIvy and VE behaviours when it comes to queries and the
`<ng-container>` elements and fixes a common bugs where a query target was placed inside the
`<ng-container>` element with a * directive on it.

Before:

```html
<needs-target>
  <ng-container *ngIf="condition">
    <div #target>...</div>  <!-- this node would NOT match -->
  </ng-container>
</needs-target>
```

After:

```html
<needs-target>
  <ng-container *ngIf="condition">
    <div #target>...</div>  <!-- this node WILL match -->
  </ng-container>
</needs-target>
```

Fixes #34768

PR Close #35384
2020-02-18 17:17:46 -08:00
crisbeto 5fbfe6996a fix(ivy): wrong context passed to ngOnDestroy when resolved multiple times (#35249)
When the same provider is resolved multiple times on the same node, the first invocation had the correct context, but all subsequent ones were incorrect because we were registering the hook multiple times under different indexes in `destroyHooks`.

Fixes #35167.

PR Close #35249
2020-02-18 17:17:05 -08:00
Andrew Kushnir c013dd4ca6 fix(core): better handing of ICUs outside of i18n blocks (#35347)
Currently the logic that handles ICUs located outside of i18n blocks may throw exceptions at runtime. The problem is caused by the fact that we store incorrect TNode index for previous TNode (index that includes HEADER_OFFSET) and do not store a flag whether this TNode is a parent or a sibling node. As a result, the logic that assembles the final output uses incorrect TNodes and in some cases throws exceptions (when incompatible structure is extracted from tView.data due to the incorrect index). This commit adjusts the index and captures whether TNode is a parent to make sure underlying logic manipulates correct TNode.

PR Close #35347
2020-02-18 12:43:44 -08:00
Kara Erickson 939e2f76f6 docs(forms): remove outdated ngForm selector deprecation notice (#35435)
In https://github.com/angular/angular/pull/33058, we removed support
for the `ngForm` selector in the NgForm directive. We deleted most
of the deprecation notices in that PR, but we missed a paragraph
of documentation in the API docs for NgForm.

This commit removes the outdated paragraph that makes it seem like
the selector is still around and deprecated (as opposed to removed),
as it might confuse users.

PR Close #35435
2020-02-14 15:34:00 -08:00
Misko Hevery 8c75f2155d fix(core): correctly concatenate static and dynamic binding to `class` when shadowed (#35350)
Given:
```
<div class="s1" [class]="null" [ngClass]="exp">
```
Notice that `[class]` binding is not a `string`. As a result the existing logic would not concatenate `[class]` with `class="s1"`. The resulting falsy value would than be sent to `ngClass` which would promptly clear all styles on the `<div>`

The new logic correctly handles falsy values for `[class]` bindings.

Fix #35335

PR Close #35350
2020-02-14 15:33:14 -08:00
Misko Hevery 2ca7984d55 fix(core): remove support for `Map`/`Set` in `[class]`/`[style]` bindings (#35392)
Close FW-1863

PR Close #35392
2020-02-14 11:14:43 -08:00
Misko Hevery b9b512f729 fix(ivy): `LFrame` needs to release memory on `leaveView()` (#35156)
Root cause is that for perf reasons we cache `LFrame` so that we don't have to allocate it all the time. To be extra fast we clear the `LFrame` on `enterView()` rather that on `leaveView()`. The implication of this strategy is that the deepest `LFrame` will retain objects until the `LFrame` allocation depth matches the deepest object.

The fix is to simply clear the `LFrame` on `leaveView()` rather then on `enterView()`

Fix #35148

PR Close #35156
2020-02-14 11:13:36 -08:00
Greg Magolan 27cd01f606 build: update to bazel_toolchains 2.1.0 (#35430)
Needed with @bazel/bazel 2.1.0 update

PR Close #35430
2020-02-13 16:29:33 -08:00
Greg Magolan 2780dcc487 build: update to @bazel/bazel 2.1.0 (#35430)
Includes new feature to honor .bazelignore in external repositories. rules_nodejs 1.3.0 now generates a .bazelignore for the @npm repository so that Bazel ignores the @npm//:node_modules folder.

PR Close #35430
2020-02-13 16:29:32 -08:00
Greg Magolan d66a8c8189 build: update to rules_nodejs 1.3.0 (#35430)
Brings in feat: builtin: expose @npm//foo__all_files filegroup that includes all files in the npm package (https://github.com/bazelbuild/rules_nodejs/commit/8d77827) that is needed for npm_integration_test @npm//puppeteer pkg_tar on OSX (as the OSX Chrrome libs are extracted to paths that contain spaces)

PR Close #35430
2020-02-13 16:29:32 -08:00
crisbeto d6bc63fa38 fix(ivy): error if directive with synthetic property binding is on same node as directive that injects ViewContainerRef (#35343)
In the `loadRenderer` we make an assumption that the value will always be an `LView`, but if there's a directive on the same node which injects `ViewContainerRef` the `LView` will be wrapped in an `LContainer`. These changes add a call to unwrap the value before we try to read the value off of it.

Fixes #35342.

PR Close #35343
2020-02-12 17:14:25 -08:00
Kara Erickson eef047bc5f fix(forms): change Array.reduce usage to Array.forEach (#35349)
There is currently a bug in Chrome 80 that makes Array.reduce
not work according to spec. The functionality in forms that
retrieves controls from FormGroups and FormArrays (`form.get`)
relied on Array.reduce, so the Chrome bug broke forms for
many users.

This commit refactors our forms code to rely on Array.forEach
instead of Array.reduce to fix forms while we are waiting
for the Chrome fix to go live.

See https://bugs.chromium.org/p/chromium/issues/detail?id=1049982.

PR Close #35349
2020-02-11 17:02:52 -08:00
Alan Agius 7c9735a995 fix(elements): schematics fails with schema.json not found error (#35211)
Fixes #35154

PR Close #35211
2020-02-11 11:42:52 -08:00
JiaLiPassion 332937ef24 feat: make mocha a zone module. (#34719)
PR Close #34719
2020-02-11 11:41:58 -08:00
Keen Yee Liau 81241af7ac fix(language-service): Suggest ? and ! operator on nullable receiver (#35200)
Under strict mode, the language service fails to typecheck nullable
symbols that have already been verified to be non-null.

This generates incorrect (false positive) and confusing diagnostics
for users.

To work around this issue in the short term, this commit changes the
diagnostic message from an error to a suggestion, and prompts users to
use the safe navigation operator (?) or non-null assertion operator (!).

For example, instead of

```typescript
{{ optional && optional.toString() }}
```

the following is cleaner:

```typescript
{{ optional?.toString() }}
{{ optional!.toString() }}
```

Note that with this change, users who legitimately make a typo in their
code will no longer see an error. I think this is acceptable, since
false positive is worse than false negative. However, if users follow
the suggestion, add ? or ! to their code, then the error will be surfaced.
This seems a reasonable trade-off.

References:

1. Safe navigation operator (?)
   https://angular.io/guide/template-syntax#the-safe-navigation-operator----and-null-property-paths
2. Non-null assertion operator (!)
   https://angular.io/guide/template-syntax#the-non-null-assertion-operator---

PR closes https://github.com/angular/angular/pull/35070
PR closes https://github.com/angular/vscode-ng-language-service/issues/589

PR Close #35200
2020-02-10 16:43:44 -08:00
ayazhafiz a92d97cda7 fix(compiler): report errors for missing binding names (#34595)
Currently, would-be binding attributes that are missing binding names
are not parsed as bindings, and fall through as regular attributes. In
some cases, this can lead to a runtime error; trying to assign `#` as a
DOM attribute in an element like in `<div #></div>` fails because `#` is
not a valid attribute name.

Attributes composed of binding prefixes but not defining a binding
should be considered invalid, as this almost certainly indicates an
unintentional elision of a binding by the developer. This commit
introduces error reporting for attributes with a binding name prefix but
no actual binding name.

Closes https://github.com/angular/vscode-ng-language-service/issues/293.

PR Close #34595
2020-02-10 16:29:32 -08:00
JiaLiPassion e1160f19be feat: make jasmine patch as zone module (#34676)
PR Close #34676
2020-02-10 16:23:47 -08:00
George Kalpakas 5f57376899 test(ngcc): add missing `UmdReflectionHost#getExportsOfModule()` tests (#35312)
Support for re-exports in UMD were added in e9fb5fdb8. This commit adds
some tests for re-exports (similar to the ones used for
`CommonJsReflectionHost`).

PR Close #35312
2020-02-10 16:13:41 -08:00
Francesco Leardini 9a55020286 docs: added description for `novalidate` form attribute. (#35166)
PR Close #35166
2020-02-10 16:11:58 -08:00
Igor Minar 76b77ec3c2 docs(forms): update the ngForm deprecation notice (#35263)
we should be documenting when an API is eligible for removal and not when it will be removed.

The actual removal depends on many factors, e.g. if we were able to automate the refactoring to
the recommended API in time or not.

PR Close #35263
2020-02-10 10:49:00 -08:00
Andrew Kushnir ae0253f34a fix(ivy): set namespace for host elements of dynamically created components (#35136)
Prior to this change, element namespace was not set for host elements of dynamically created components that resulted in incorrect rendering in a browser. This commit adds the logic to pick and set correct namespace for host element when component is created dynamically.

PR Close #35136
2020-02-07 17:22:53 -08:00
JoostK 5de5b52beb fix(ivy): repeat template guards to narrow types in event handlers (#35193)
In Ivy's template type checker, event bindings are checked in a closure
to allow for accurate type inference of the `$event` parameter. Because
of the closure, any narrowing effects of template guards will no longer
be in effect when checking the event binding, as TypeScript assumes that
the guard outside of the closure may no longer be true once the closure
is invoked. For more information on TypeScript's Control Flow Analysis,
please refer to https://github.com/microsoft/TypeScript/issues/9998.

In Angular templates, it is known that an event binding can only be
executed when the view it occurs in is currently rendered, hence the
corresponding template guard is known to hold during the invocation of
an event handler closure. As such, it is desirable that any narrowing
effects from template guards are still in effect within the event
handler closure.

This commit tweaks the generated Type-Check Block (TCB) to repeat all
template guards within an event handler closure. This achieves the
narrowing effect of the guards even within the closure.

Fixes #35073

PR Close #35193
2020-02-07 13:06:00 -08:00
JiaLiPassion daac33cdc8 feat: add basic jest support (#35080)
PR Close #35080
2020-02-07 11:43:21 -08:00
Pete Bacon Darwin 54c3a5da3f fix(ngcc): ensure that path-mapped secondary entry-points are processed correctly (#35227)
The `TargetedEntryPointFinder` must work out what the
containing package is for each entry-point that it finds.

The logic for doing this was flawed in the case that the
package was in a path-mapped directory and not in a
node_modules folder. This meant that secondary entry-points
were incorrectly setting their own path as the package
path, rather than the primary entry-point path.

Fixes #35188

PR Close #35227
2020-02-07 11:32:05 -08:00
Stephen Fluin b5fa4b58ca docs: improve description of providedIn any (#35192)
PR Close #35192
2020-02-07 09:59:09 -08:00
Andrew Scott 0cbdd54fd0 fix(ivy): ensure module imports are instantiated before the module being declared (#35172)
PR Close #35172
2020-02-07 09:58:49 -08:00
Alan Agius dcff6c9940 fix(bazel): spawn prod server using port 4200 (#35160)
Currently the prod server uses a default port of 8080, with this change we align the port with the devserver.

PR Close #35160
2020-02-06 15:35:11 -08:00
Alan Agius 129010e4c2 fix(bazel): devserver shows blank page in Windows (#35159)
`additional_root_paths` should contain the workspace name see: d4200191c5/packages/typescript/src/internal/devserver/ts_devserver.bzl (L137-L140)

Fixes #35144

PR Close #35159
2020-02-06 15:34:30 -08:00
Alan Agius 6fb538ed1d fix(bazel): update ibazel to 0.11.1 (#35158)
PR Close #35158
2020-02-06 15:33:26 -08:00
Alex Rickabaugh 3c69442dbd feat(compiler-cli): implement NgTscPlugin on top of the NgCompiler API (#34792)
This commit implements an experimental integration with tsc_wrapped, where
it can load the Angular compiler as a plugin and perform Angular
transpilation at a user's request.

This is an alternative to the current ngc_wrapped mechanism, which is a fork
of tsc_wrapped from several years ago. tsc_wrapped has improved
significantly since then, and this feature will allow Angular to benefit
from those improvements.

Currently the plugin API between tsc_wrapped and the Angular compiler is a
work in progress, so NgTscPlugin does not yet implement any interfaces from
@bazel/typescript (the home of tsc_wrapped). Instead, an interface is
defined locally to guide this standardization.

PR Close #34792
2020-02-06 15:27:34 -08:00
Alex Rickabaugh 14aa6d090e refactor(ivy): compute ignoreFiles for compilation on initialization (#34792)
This commit moves the calculation of `ignoreFiles` - the set of files to be
ignored by a consumer of the `NgCompiler` API - from its `prepareEmit`
operation to its initialization. It's now available as a field on
`NgCompiler`.

This will allow a consumer to skip gathering diagnostics for `ignoreFiles`
as well as skip emit.

PR Close #34792
2020-02-06 15:27:34 -08:00
Alex Rickabaugh c35671c0a4 fix(ivy): template type-check errors from TS should not use NG error codes (#35146)
A bug previously caused the template type-checking diagnostics produced by
TypeScript for template expressions to use -99-prefixed error codes. These
codes are converted to "NG" errors instead of "TS" errors during diagnostic
printing. This commit fixes the issue.

PR Close #35146
2020-02-04 15:59:01 -08:00
Miško Hevery d528dedd50 refactor(ivy): Explicitly pass in `TView` (#35069)
- Adds `TView` into `LFrame`, read the `TView` from `LView` on `enterView`.
- Before this change the `TView` was ofter looked up from `LView` as `lView[TVIEW]`. This is suboptimal since reading from an Array, requires that the read checks array size before the read. This means that such a read has a much higher cost than reading from the property directly. By passing in the `TView` explicitly it makes the code more explicit and faster.
- Some rearrangements of arguments so that `TView` would come before `LView` for consistency.

PR Close #35069
2020-02-04 12:56:47 -08:00
Miško Hevery 770980de69 test(ivy): fix broken tests (#35069)
PR Close #35069
2020-02-04 12:56:47 -08:00
Sonu Kapoor 7fb66eca25 docs: changes AoT to AOT for consistency (#35112)
PR Close #35112
2020-02-04 10:43:33 -08:00
JoostK 6ddf5508db fix(ivy): support emitting a reference to interface declarations (#34849)
In #34021 the ngtsc compiler gained the ability to emit type parameter
constraints, which would generate imports for any type reference that
is used within the constraint. However, the `AbsoluteModuleStrategy`
reference emitter strategy did not consider interface declarations as a
valid declaration it can generate an import for, throwing an error
instead.

This commit fixes the issue by including interface declarations in the
logic that determines whether something is a declaration.

Fixes #34837

PR Close #34849
2020-02-04 10:40:45 -08:00
JoostK 5cada5cce1 fix(ivy): recompile on template change in ngc watch mode on Windows (#34015)
In #33551, a bug in `ngc --watch` mode was fixed so that a component is
recompiled when its template file is changed. Due to insufficient
normalization of files paths, this fix did not have the desired effect
on Windows.

Fixes #32869

PR Close #34015
2020-02-04 10:40:22 -08:00
George Kalpakas 523c785e8f fix(ngcc): correctly invalidate cache when moving/removing files/directories (#35106)
One particular scenario where this was causing problems was when the
[BackupFileCleaner][1] restored a file (such as a `.d.ts` file) by
[moving the backup file][2] to its original location, but the modified
content was kept in the cache.

[1]: https://github.com/angular/angular/blob/4d36b2f6e/packages/compiler-cli/ngcc/src/writing/cleaning/cleaning_strategies.ts#L54
[2]: https://github.com/angular/angular/blob/4d36b2f6e/packages/compiler-cli/ngcc/src/writing/cleaning/cleaning_strategies.ts#L61

Fixes #35095

PR Close #35106
2020-02-03 14:25:47 -08:00
JiaLiPassion 3c30474417 docs: update zone-bluebird patch document for angular (#34536)
PR Close #34536
2020-02-03 14:05:22 -08:00
George Kalpakas 9601b5d18a refactor(ngcc): remove unused function (#35122)
Since #35057, the `markNonAngularPackageAsProcessed()` function is no
longer used and can be removed.

PR Close #35122
2020-02-03 14:04:59 -08:00
Miško Hevery ab931cf872 fix(ivy): host-styling throws assert exception inside *ngFor (#35133)
Inside `*ngFor` the second run of the styling instructions can get into situation where it tries to read a value from a binding which has not yet executed. As a result the read is `NO_CHANGE` value and subsequent property read cause an exception as it is of wrong type.

Fix #35118

PR Close #35133
2020-02-03 14:03:40 -08:00
Keen Yee Liau a8609ba0ad refactor(language-service): dedupe diagnostics using ts utility function (#35086)
This commit makes a minor refactoring that replaces `uniqueBySpan` with
`ts.sortAndDeduplicateDiagnostics()`.

PR Close #35086
2020-02-03 08:57:58 -08:00
Keen Yee Liau c8584e5d36 refactor(language-service): Replace TypeDiagnostic with ng.Diagnostic (#35085)
This commit cleans up `expression_type.ts` by

1. Removing the unnecessary `TypeDiagnostic` class. It's replaced by
`ng.Diagnostic`.
2. Consolidating `reportError()` and `reportWarning()` to
`reportDiagnostic()`.

This is prep work so that we could make some of the type diagnostics a
suggestion in later PRs.

PR Close #35085
2020-02-03 08:57:18 -08:00
Misko Hevery 01308e4c7c refactor(ivy): Remove `TNode.directives` in favor of `TData` (#35050)
`TNode.directives` was introduced in https://github.com/angular/angular/pull/34938. Turns out that it is unnecessary because the information is already present it `TData` when combining with `TNode.directiveStart` and `TNode.directiveEnd`

Mainly this is true (conceptually):
```
expect(tNode.directives).toEqual(
    tData.slice(
        tNode.directivesStart,
        tNode.directivesEnd - tNode.DirectivesStart -1
    )
);
```

The refactoring removes `TNode.directives` and adds `TNode.directiveStyling` as we still need to keep location in the directive in `TNode`

PR Close #35050
2020-02-03 08:56:51 -08:00
Misko Hevery 65dbd50594 test(ivy): correct var count in perf benchmarks. (#35071)
These tests are used for perf testing and don't run as part of CI, as a result they bit-rotted. This fixes that. Long term these tests should be run as part of CI.

PR Close #35071
2020-02-03 08:48:41 -08:00
Pete Bacon Darwin 3d4067a464 fix(ngcc): do not lock if the target is not compiled by Angular (#35057)
To support parallel CLI builds we instruct developers to pre-process
their node_modules via ngcc at the command line.

Despite doing this ngcc was still trying to set a lock when it was being
triggered by the CLI for packages that are not going to be processed,
since they are not compiled by Angular for instance.

This commit checks whether a target package needs to be compiled
at all before attempting to set the lock.

Fixes #35000

PR Close #35057
2020-02-03 08:46:43 -08:00
JiaLiPassion a3c7ab99b7 feat: performance improvement for eventListeners (#34613)
PR Close #34613
2020-02-03 08:40:49 -08:00
Pete Bacon Darwin 2bfddcf29f feat(ngcc): automatically clean outdated ngcc artifacts (#35079)
If ngcc gets updated to a new version then the artifacts
left in packages that were processed by the previous
version are possibly invalid.

Previously we just errored if we found packages that
had already been processed by an outdated version.

Now we automatically clean the packages that have
outdated artifacts so that they can be reprocessed
correctly with the current ngcc version.

Fixes #35082

PR Close #35079
2020-01-31 17:02:44 -08:00
Pete Bacon Darwin 2e52fcf1eb refactor(compiler-cli): add `removeDir()` to `FileSystem` (#35079)
PR Close #35079
2020-01-31 17:02:44 -08:00
Pete Bacon Darwin 16e15f50d2 refactor(ngcc): export magic strings as constants (#35079)
These strings will be used when cleaning up outdated
packages.

PR Close #35079
2020-01-31 17:02:43 -08:00
Pete Bacon Darwin 3cf55c195b refactor(ngcc): add additional build marker helpers (#35079)
PR Close #35079
2020-01-31 17:02:43 -08:00
Pete Bacon Darwin cc43bfa725 refactor(ngcc): do not crash if package build version is outdated (#35079)
Now `hasBeenProcessed()` will no longer throw if there
is an entry-point that has been built with an outdated
version of ngcc.

Instead it just returns `false`, which will include it in this
processing run.

This is a precursor to adding functionality that will
automatically revert outdate build artifacts.

PR Close #35079
2020-01-31 17:02:43 -08:00
Pete Bacon Darwin 171a79d04f refactor(ngcc): remove unused code (#35079)
PR Close #35079
2020-01-31 17:02:43 -08:00
Alan Agius 6d11a81994 fix(compiler-cli): add `sass` as a valid css preprocessor extension (#35052)
`.sass` is a valid preprocessor extension which is used for Sass indented syntax

https://sass-lang.com/documentation/syntax

PR Close #35052
2020-01-31 13:28:39 -08:00
JiaLiPassion 58b29f1503 fix: should also allow subclass Promise without Symbol.species (#34533)
PR Close #34533
2020-01-31 13:17:59 -08:00
Greg Magolan 60018d265f build: update to rules_nodejs 1.2.2 (#34961)
Fixes issue with yarn_install not following yarn-path in .yarnrc when bazel run from yarn with `yarn bazel ...` (rules_nodejs: fix: unset YARN_IGNORE_PATH in yarn_install before calling yarn #1588)

PR Close #34961
2020-01-31 13:14:05 -08:00
Greg Magolan da604310c6 build: update to rules_nodejs 1.2.1 (#34961)
Fixes issue with conflicting linker module mappings introduced in 1.2.0

PR Close #34961
2020-01-31 13:14:05 -08:00
Greg Magolan 513c69169e build: update to rules_nodejs 1.2.0 (#34961)
This brings in a fix so that yarn_install picks up the yarn-path attribute of the .yarnrc file.

PR Close #34961
2020-01-31 13:14:05 -08:00
cexbrayat c77cf717aa test(common): unit test for http/testing expectOne with several requests (#27005)
PR Close #27005
2020-01-31 13:13:38 -08:00
cexbrayat 115b7e42c6 fix(common): http/testing expectOne lists the received requests if no matches (#27005)
Fixes #18013

Previously it was hard to debug an `expectOne` if the request had no match, as the error message was:

    Expected one matching request for criteria "Match URL: /some-url?query=hello", found none.

This commit adds a bit more info to the error, by listing the actual requests received:

    Expected one matching request for criteria "Match URL: /some-url?query=hello", found none. Requests received are: POST /some-url?query=world.

PR Close #27005
2020-01-31 13:13:37 -08:00
cexbrayat a622a281d3 test(common): unit tests for http/testing expectOne (#27005)
PR Close #27005
2020-01-31 13:13:37 -08:00
cexbrayat fcfce99e9e fix(common): remove extra & in http params (#34896)
Previous to this commit, HTTP params like `{ a: '1', b: [], c: '3' }` resulted in a request like `a=1&&c=3` (note the double &&).

The ideal fix would probably be to stringify these params to `a=1&b=&c=3` like we do for empty string values. But that might be breaking as some APIs may rely on the absence of the parameter.

This fixes the issue in a compatible way by just removing the extra and unnecessary `&`, resulting in `a=1&c=3`.

PR Close #34896
2020-01-31 11:26:25 -08:00
Igor Minar c070037357 refactor(compiler): rename diagnostics/src/code.ts to diagnostics/src/error_code.ts (#35067)
the new filename is less ambiguous and better reflects the name of the symbol defined in it.

PR Close #35067
2020-01-31 11:25:27 -08:00
Alex Rickabaugh 9f5b490800 Revert "refactor(compiler): refactor and export Bazel host creation. (#34686)" (#35063)
This reverts commit cb142b6df9.

The intention of this commit was for a consumer of the `compile` function to
pass the `bazelHost` it returns into future invocations, reusing the
`FileCache` between them. However, first-party ngc_wrapped does not do this,
which caused a performance regression as the `FileCache` was no longer
shared between compilations.

PR Close #35063
2020-01-30 12:02:10 -08:00
Kristiyan Kostadinov cd9ae66b35 refactor(ivy): remove markDirty from global utilities (#34453)
Removes `markDirty` from the global debugging utilities API since we've already exposed `detectChanges`.

PR Close #34453
2020-01-30 11:30:32 -08:00
crisbeto 471375adbe docs(ivy): document global debugging utilities and clean up API (#34453)
Cleans up the public API of the global debugging utilities, documents them and exposes them in the API docs.

PR Close #34453
2020-01-30 11:30:32 -08:00
Alex Rickabaugh 37f39d6db5 build(compiler-cli): update to chokidar 3.x (#35047)
Update from chokidar 2.x to 3.x in ngc/ngtsc, to eliminate any possibility
of a security issue with a downstream dependency of the package.

FW-1809 #resolve

PR Close #35047
2020-01-30 08:41:13 -08:00
Miško Hevery c1cf46c5c3 refactor(ivy): clean of #34804 from previous merge (#35022)
This is a follow up for https://github.com/angular/angular/pull/34804

PR Close #35022
2020-01-29 16:35:08 -08:00
Misko Hevery ee8b8f52aa feat(ivy): Change static priority resolution to be same level as directive it belongs to (#34938)
This change changes the priority order of static styling.

Current priority:
```
(least priority)
- Static
  - Component
  - Directives
  - Template
- Dynamic Binding
  - Component
    - Map/Interpolation
    - Property
  - Directives
    - Map/Interpolation
    - Property
  - Template
    - Map/Interpolation
    - Property
(highest priority)
```

The issue with the above priority is this use case:

```
<div style="color: red;" directive-which-sets-color-blue>
```
In the above case the directive will win and the resulting color will be `blue`. However a small change of adding interpolation to the example like so. (Style interpolation is coming in https://github.com/angular/angular/pull/34202)
```
<div style="color: red; width: {{exp}}px" directive-which-sets-color-blue>
```
Changes the priority from static binding to interpolated binding which means now the resulting color is `red`. It is very surprising that adding an unrelated interpolation and style can change the `color` which was not changed. To fix that we need to make sure that the static values are associated with priority of the source (directive or template) where they were declared. The new resulting priority is:

```
(least priority)
- Component
  - Static
  - Map/Interpolation
  - Property
- Directives
  - Static
  - Map/Interpolation
  - Property
- Template
  - Static
  - Map/Interpolation
  - Property
(highest priority)
```

PR Close #34938
2020-01-29 15:41:47 -08:00
Misko Hevery cf07d428a1 refactor(ivy): make assert conditions more readable (#34938)
PR Close #34938
2020-01-29 15:41:47 -08:00
Adam 17650523a8 build: remove unneeded style code for ngClass and ngStyle (#34998)
With the release of Flex Layout v9.0.0-beta.28, some added code
after the recent styling refactor is no longer needed.

PR Close #34998
2020-01-29 14:57:21 -08:00
Andrew Scott b8ffcf973c fix(ivy): update ViewContainerRef to get the correct parentInjector (#35013)
PR Close #35013
2020-01-29 12:46:04 -08:00
Andrew Scott 4a5467bac6 fix(ivy): ensure multi providers in ModuleWithProviders are not duplicated (#34914)
The current logic pulls multiproviders up to the parent module's
provider list. The result is that the multi provider being defined both in
the imported ModuleWithProviders and the parent and getting an extra
item in the multi provided array of values. This PR fixes that problem
by not pulling providers in ModuleWithProviders up to the parent module.

PR Close #34914
2020-01-29 12:22:58 -08:00
Ayaz Hafiz b608fa55f0 fix(language-service): warn, not error, on missing context members (#35036)
The language service reports an error when a directive's template
context is missing a member that is being used in a template (e.g. if
`$implicit` is being used with a template context typed as `any`).
While this diagnostic message is valuable, typing template contexts
loosely as `any` or `object` is very widespread in community packages,
and often still compiles correctly, so reporting the diagnostic as an
error may be misleading to users.

This commit changes the diagnostic to be a warning, and adds additional
information about how the user can eliminate the warning entirely -- by
refining the template context type.

Closes https://github.com/angular/vscode-ng-language-service/issues/572

PR Close #35036
2020-01-29 12:22:09 -08:00
ayazhafiz b64ead5cb8 fix(language-service): prune duplicate returned definitions (#34995)
Sometimes, a request for definitions will return multiple of the same
definition. This can happen in at least the cases of

- two-way bindings (one of the same definition for the property and
  event binding)
- multiple template binding expressions in the same attribute
  - something like "*ngFor="let i of items; trackBy: test" has two
    template bindings, resulting in two template binding ASTs at the
    same location (the attribute span). The language service then parses
    both of these bindings individually, resulting in two independent
    but identical definitions. For more context, see https://github.com/angular/angular/pull/34847#discussion_r371006680.

This commit prunes duplicate definitions by signing definitions with
their location, and checking if that location signature has been seen in
a previous definition returned to the client.

PR Close #34995
2020-01-29 12:21:04 -08:00
Pete Bacon Darwin fb852f7252 build(localize): sync up babel dependencies (#35008)
In #34974 the top level dependency on `@babel/core` was bumped to
7.8.3. This commit ensures that the package.json that gets included
in the `@angular/localize` distributable is at the same version.

PR Close #35008
2020-01-29 09:24:08 -08:00
George Kalpakas 669df70da5 fix(ivy): ensure `DebugNode`/`DebugElement` are tree-shakeable in Ivy (#35003)
There are different `DebugNode`/`DebugElement` implementations (and
associated helper functions) for ViewEngine and Ivy. Additionally, these
classes/functions, which are defined inside the `core` package, are
imported by the `platform-browser` package.

Previously, this code was not tree-shaken as expected in Ivy. #30130
partially addressed the issue, but only for the case where `core` and
`platform-browser` end up in the same closure after webpack's scope
hoisting. In cases where this is not the case, our webpack/terser based
tooling is not capable of tree-shaking it.

This commit fixes the problem, by ensuring that the code retained in Ivy
mode (due to the cross-package import) does not unnecessarily reference
`DebugNode`/`DebugElement`, allowing the code to be tree-shaken away.
This results in a 7.6KB reduction in the size of the main angular.io
bundle.

Jira issue: [FW-1802](https://angular-team.atlassian.net/browse/FW-1802)

PR Close #35003
2020-01-28 15:57:57 -08:00
George Kalpakas 0f02e66170 refactor(core): order private exports alphabetically (#35003)
PR Close #35003
2020-01-28 15:57:57 -08:00
George Kalpakas 9e351b8fe1 refactor: remove unused imports (#35003)
PR Close #35003
2020-01-28 15:57:57 -08:00
Pete Bacon Darwin 7f44fa65a7 fix(ngcc): improve lockfile error message (#35001)
The message now gives concrete advice to developers who
experience the error due to running multiple simultaneous builds
via webpack.

Fixes #35000

PR Close #35001
2020-01-28 09:09:00 -08:00
ayazhafiz e7c74cbd69 feat(language-service): completions for output $event properties in (#34570)
This commit adds support for completions of properties on `$event`
variables in bound outputs.

This is the second major PR to support completions for `$event`
variables (https://github.com/angular/vscode-ng-language-service/issues/531).
The final completion support that must be provided is for `$event`
variables in bindings targeting DOM events, like `(click)`.

PR Close #34570
2020-01-28 09:07:43 -08:00
ayazhafiz 24864ee71e feat(language-service): provide completion for $event variable (#34570)
This commit adds a completion for the `$event` variable in bound event
expressions.

This is the first in a series of PRs to support completions for
properties on `$event` variables (https://github.com/angular/vscode-ng-language-service/issues/531).

PR Close #34570
2020-01-28 09:07:43 -08:00
Ayaz Hafiz 90b303faa3 refactor(language-service): make findOutputBinding a utility function (#34997)
This commit makes `findOutputBinding` a utility function for the
language service, which will be used by the `expression_diagnostics`
module in #34570. Keeping the function in `locate_symbol` results in a
circular dependency between `expression_diagnostics` and
`locate_symbol`.

PR Close #34997
2020-01-27 15:53:57 -08:00
Kristiyan Kostadinov 304584c291 perf(ivy): remove unused argument in hostBindings function (#34969)
We had some logic for generating and passing in the `elIndex` parameter into the `hostBindings` function, but it wasn't actually being used for anything. The only place left that had a reference to it was the `StylingBuilder` and it only stored it without referencing it again.

PR Close #34969
2020-01-27 12:49:35 -08:00
Pete Bacon Darwin 7069a83727 fix(localize): re-enable filename in code-frame error messages (#34994)
These were removed in 4c3a543f7f
due to a breaking change in an update to `babel-core`. See
dcf7d89b8e

This commit adds back in the filename to these messages.

Resolves https://github.com/angular/angular/pull/34974/files#r371034476

PR Close #34994
2020-01-27 12:25:40 -08:00
Andrew Kushnir 6e5cfd2cd2 fix(ivy): catch FatalDiagnosticError thrown from preanalysis phase (#34801)
Component's decorator handler exposes `preanalyze` method to preload async resources (templates, stylesheets). The logic in preanalysis phase may throw `FatalDiagnosticError` errors that contain useful information regarding the origin of the problem. However these errors from preanalysis phase were not intercepted in TraitCompiler, resulting in just error message text be displayed. This commit updates the logic to handle FatalDiagnosticError and transform it before throwing, so that the result diagnostic errors contain the necessary info.

PR Close #34801
2020-01-27 10:58:27 -08:00
ivanwonder 09869af90f fix(language-service): remove repeated symbol definitions for structural directive (#34847)
For the structural directive, the 'path' will contain multiple `BoundDirectivePropertyAst` which depends on the number of directive property in the attribute value(e.g. '*ngFor="let item of []; trackBy: test;"', it has 2 `BoundDirectivePropertyAst`, 'ngForOf' and 'ngForTrackBy').

PR Close #34847
2020-01-27 10:47:46 -08:00
ivanwonder e7dff9eb0c feat(language-service): provide hover for microsyntax in structural directive (#34847)
PR Close #34847
2020-01-27 10:47:46 -08:00
Joey Perrott 8fbb48cc2e build: migrate to node@12.14.1 (#34955)
PR Close #34955
2020-01-27 09:31:22 -08:00
Igor Minar 4c3a543f7f test(localize): fix broken localize/translate tests (#34974)
the test failures most likely result from the babel updates in the previous commit.

it does look like we lost the file path from the error message, which is something that we

should follow up no in a separate change.

PR Close #34974
2020-01-26 14:53:47 -08:00
Igor Minar 7360e1ea2c build: add missing @babel/core bazel dep to fix //packages/localize/src/tools/test:test_lib (#34974)
Previously we relied on this package being hoisted and available, which is error prone and it would
be just a matter of time before the build would break due rehoisting of deps upon future npm package.json
changes.

PR Close #34974
2020-01-26 14:53:47 -08:00