Commit Graph

15787 Commits

Author SHA1 Message Date
Keen Yee Liau 65a0d2b53d fix(language-service): Preserve CRLF in templates for language-service (#33241)
This is a potential fix for https://github.com/angular/vscode-ng-language-service/issues/235
suggested by @andrius-pra in
47696136e3.

Currently, CRLF line endings are converted to LFs and this causes the
diagnostics span to be off in templates that use CRLF. The line endings
must be preserved in order to maintain correct span offset. The solution
is to add an option to the Tokenizer to indicate such preservation.

PR Close #33241
2019-10-22 13:29:23 -04:00
Alex Rickabaugh e030375d9a feat(ngcc): enable private NgModule re-exports in ngcc on request (#33177)
This commit adapts the private NgModule re-export system (using aliasing) to
ngcc. Not all ngcc compilations are compatible with these re-exports, as
they assume a 1:1 correspondence between .js and .d.ts files. The primary
concern here is supporting them for commonjs-only packages.

PR Close #33177
2019-10-22 13:14:31 -04:00
Alex Rickabaugh c4733c15c0 feat(ivy): enable re-export of the compilation scope of NgModules privately (#33177)
This commit refactors the aliasing system to support multiple different
AliasingHost implementations, which control specific aliasing behavior
in ngtsc (see the README.md).

A new host is introduced, the `PrivateExportAliasingHost`. This solves a
longstanding problem in ngtsc regarding support for "monorepo" style private
libraries. These are libraries which are compiled separately from the main
application, and depended upon through TypeScript path mappings. Such
libraries are frequently not in the Angular Package Format and do not have
entrypoints, but rather make use of deep import style module specifiers.
This can cause issues with ngtsc's ability to import a directive given the
module specifier of its NgModule.

For example, if the application uses a directive `Foo` from such a library
`foo`, the user might write:

```typescript
import {FooModule} from 'foo/module';
```

In this case, foo/module.d.ts is path-mapped into the program. Ordinarily
the compiler would see this as an absolute module specifier, and assume that
the `Foo` directive can be imported from the same specifier. For such non-
APF libraries, this assumption fails. Really `Foo` should be imported from
the file which declares it, but there are two problems with this:

1. The compiler would have to reverse the path mapping in order to determine
   a path-mapped path to the file (maybe foo/dir.d.ts).
2. There is no guarantee that the file containing the directive is path-
   mapped in the program at all.

The compiler would effectively have to "guess" 'foo/dir' as a module
specifier, which may or may not be accurate depending on how the library and
path mapping are set up.

It's strongly desirable that the compiler not break its current invariant
that the module specifier given by the user for the NgModule is always the
module specifier from which directives/pipes are imported. Thus, for any
given NgModule from a particular module specifier, it must always be
possible to import any directives/pipes from the same specifier, no matter
how it's packaged.

To make this possible, when compiling a file containing an NgModule, ngtsc
will automatically add re-exports for any directives/pipes not yet exported
by the user, with a name of the form: ɵngExportɵModuleNameɵDirectiveName

This has several effects:

1. It guarantees anyone depending on the NgModule will be able to import its
   directives/pipes from the same specifier.
2. It maintains a stable name for the exported symbol that is safe to depend
   on from code on NPM. Effectively, this private exported name will be a
   part of the package's .d.ts API, and cannot be changed in a non-breaking
   fashion.

Fixes #29361
FW-1610 #resolve

PR Close #33177
2019-10-22 13:14:31 -04:00
Joey Perrott a86a179f45 build: use http caching on windows CI runs (#33298)
PR Close #33298
2019-10-22 13:09:28 -04:00
TinyMan ec482dadb1 docs: clarrify use of sw behind redirect (#32915)
Closes #30684

PR Close #32915
2019-10-21 16:50:52 -04:00
David Sánchez 427a1ccd9a docs: clarify steps in Hosting on Firebase (#33089)
PR Close #33089
2019-10-21 16:07:04 -04:00
Colum Ferry 403bb6bee3 docs(forms): fix grammar and add clarification to setValue docs (#33126)
Changed `setValue` documentation for throwing an error as it contained a grammar
mistake and also may have caused ambiguity around when exactly the
method would throw.

PR Close #33126
2019-10-21 15:58:38 -04:00
Joey Perrott 418e9cf3c4 build: address comments, restructure setup-rbe.sh script (#33109)
PR Close #33109
2019-10-21 15:56:52 -04:00
Joey Perrott fa0ab38546 build: update circleci config to handle GOOGLE_APPLICATION_CREDENTIALS for all linux bazel builds (#33109)
PR Close #33109
2019-10-21 15:56:51 -04:00
Joey Perrott 3b643b8f3c docs: update DEVELOPER.md to include information about RBE and remote caching (#33109)
PR Close #33109
2019-10-21 15:56:51 -04:00
Joey Perrott 37a87418b6 build: migrate to using google_default_credentials and update setup-rbe script (#33109)
PR Close #33109
2019-10-21 15:56:51 -04:00
Joey Perrott 2ea52b0cb9 build: remove cache upload and download flags from build:remote config as they are redundant (#33109)
PR Close #33109
2019-10-21 15:56:51 -04:00
Joey Perrott 931739ac73 build: remove BES config until BES API can be used by end user accounts (#33109)
PR Close #33109
2019-10-21 15:56:51 -04:00
Carlos Ortiz García 717bace7ba docs(core): Document TestBed.get deprecation (#32974)
It was replaced by TestBed.inject, documenting such change.

PR Close #32974
2019-10-21 15:54:42 -04:00
Filipe Silva 9de4b1c441 test: fix typo in cli e2e descriptions (#33175)
PR Close #33175
2019-10-21 15:54:06 -04:00
Filipe Silva ff36a8daf6 test: disable es5 size tracking in integration tests (#33175)
PR Close #33175
2019-10-21 15:54:06 -04:00
Filipe Silva 8e2e1f8340 test: update integration/cli-hello-world-ivy-minimal project structure (#33175)
PR Close #33175
2019-10-21 15:54:06 -04:00
Filipe Silva 3ae72dccfb test: update integration/cli-hello-world-ivy-i18n project structure (#33175)
PR Close #33175
2019-10-21 15:54:06 -04:00
Filipe Silva 3f273f8d63 test: update integration/cli-hello-world-ivy-compat project structure (#33175)
PR Close #33175
2019-10-21 15:54:06 -04:00
Filipe Silva fbf6ec8813 test: update integration/cli-hello-world project structure (#33175)
PR Close #33175
2019-10-21 15:54:06 -04:00
Adam Plumer 56731f624a feat(core): add ModuleWithProviders generic type migration (#33217)
Static methods that return a type of ModuleWithProviders currently
do not have to specify a type because the generic falls back to any.
This is problematic because the type of the actual module being
returned is not present in the type information.

Since Ivy uses d.ts files exclusively for downstream packages
(rather than metadata.json files, for example), we no longer have
the type of the actual module being created.

For this reason, a generic type should be added for
ModuleWithProviders that specifies the module type. This will be
required for all users in v10, but will only be necessary for
users of Ivy in v9.

PR Close #33217
2019-10-21 15:53:28 -04:00
Matias Niemelä e5081bcf25 build: update the integration/payloads limit 2019-10-21 09:50:22 -07:00
Matias Niemelä c0ebecf54d revert: feat(ivy): input type coercion for template type-checking (#33243) (#33299)
This reverts commit 1b4eaea6d4.

PR Close #33299
2019-10-21 12:00:24 -04:00
Diego Juliao 160547dad6 docs: update deployers table with ngx-deploy-npm (#33269)
ngx-deploy-npm is a custom deployer to publish Angular libraries to NPM

PR Close #33269
2019-10-21 11:28:18 -04:00
Filipe Silva 6471a2668e test: add integration test for lazy chunks in cli apps using experimentalRollupPass (#32957)
PR Close #32957
2019-10-21 11:27:43 -04:00
Filipe Silva 609d2557bc test: add integration test for lazy chunks and ngDevMode in cli apps (#32957)
PR Close #32957
2019-10-21 11:27:43 -04:00
Filipe Silva abd2a58c67 test: update Angular CLI deps for integration tests (#32957)
PR Close #32957
2019-10-21 11:27:42 -04:00
George Kalpakas d7dc6cbc04 refactor(compiler-cli): remove unused method `FileSystem#mkdir()` (#33237)
Previously, the `FileSystem` abstraction featured a `mkdir()` method. In
`NodeJSFileSystem` (the default `FileSystem` implementation used in
actual code), the method behaved similar to Node.js' `fs.mkdirSync()`
(i.e. failing if any parent directory is missing or the directory exists
already). In contrast, `MockFileSystem` (which is the basis or mock
`FileSystem` implementations used in tests) implemented `mkdir()` as an
alias to `ensureDir()`, which behaved more like Node.js'
`fs.mkdirSync()` with the `recursive` option set to `true` (i.e.
creating any missing parent directories and succeeding if the directory
exists already).

This commit fixes this inconsistency by removing the `mkdir()` method,
which was not used anyway and only keeping `ensureDir()` (which is
consistent across our different `FileSystem` implementations).

PR Close #33237
2019-10-21 11:26:57 -04:00
George Kalpakas 8017229292 fix(ngcc): do not fail when multiple workers try to create the same directory (#33237)
When `ngcc` is running in parallel mode (usually when run from the
command line) and the `createNewEntryPointFormats` option is set to true
(e.g. via the `--create-ivy-entry-points` command line option), it can
happen that two workers end up trying to create the same directory at
the same time. This can lead to a race condition, where both check for
the directory existence, see that the directory does not exist and both
try to create it, with the second failing due the directory's having
already been created by the first one. Note that this only affects
directories and not files, because `ngcc` tasks operate on different
sets of files.

This commit avoids this race condition by allowing `FileSystem`'s
`ensureDir()` method to not fail if one of the directories it is trying
to create already exists (and is indeed a directory). This is fine for
the `ensureDir()` method, since it's purpose is to ensure that the
specified directory exists. So, even if the `mkdir()` call failed
(because the directory exists), `ensureDir()` has still completed its
mission.

Related discussion: https://github.com/angular/angular/pull/33049#issuecomment-540485703
FW-1635 #resolve

PR Close #33237
2019-10-21 11:26:57 -04:00
Alan Agius 755a80c7ec docs: update universal docs for new ivy implementation (#33040)
PR Close #33040
2019-10-21 11:25:44 -04:00
Alex Rickabaugh 1b4eaea6d4 feat(ivy): input type coercion for template type-checking (#33243)
Often the types of an `@Input`'s field don't fully reflect the types of
assignable values. This can happen when an input has a getter/setter pair
where the getter always returns a narrow type, and the setter coerces a
wider value down to the narrow type.

For example, you could imagine an input of the form:

```typescript
@Input() get value(): string {
  return this._value;
}

set value(v: {toString(): string}) {
  this._value = v.toString();
}
```

Here, the getter always returns a `string`, but the setter accepts any value
that can be `toString()`'d, and coerces it to a string.

Unfortunately TypeScript does not actually support this syntax, and so
Angular users are forced to type their setters as narrowly as the getters,
even though at runtime the coercion works just fine.

To support these kinds of patterns (e.g. as used by Material), this commit
adds a compiler feature called "input coercion". When a binding is made to
the 'value' input of a directive like MatInput, the compiler will look for a
static function with the name ngCoerceInput_value. If such a function is
found, the type-checking expression for the input will be wrapped in a call
to the function, allowing for the expression of a type conversion between
the binding expression and the value being written to the input's field.

To solve the case above, for example, MatInput might write:

```typescript
class MatInput {
  // rest of the directive...

  static ngCoerceInput_value(value: {toString(): string}): string {
    return null!;
  }
}
```

FW-1475 #resolve

PR Close #33243
2019-10-21 11:25:07 -04:00
Alex Rickabaugh d4db746898 feat(ivy): give shim generation its own compiler options (#33256)
As a hack to get the Ivy compiler ngtsc off the ground, the existing
'allowEmptyCodegenFiles' option was used to control generation of ngfactory
and ngsummary shims during compilation. This option was selected since it's
enabled in google3 but never enabled in external projects.

As ngtsc is now mature and the role shims play in compilation is now better
understood across the ecosystem, this commit introduces two new compiler
options to control shim generation:

* generateNgFactoryShims controls the generation of .ngfactory shims.
* generateNgSummaryShims controls the generation of .ngsummary shims.

The 'allowEmptyCodegenFiles' option is still honored if either of the above
flags are not set explicitly.

PR Close #33256
2019-10-21 11:24:26 -04:00
Matias Niemelä 29bc3a775f build: fix internal Google closure issue with TS3.6 (#33257)
This patch fixes an internal Google issue that came up with the TS3.6
patch that landed earlier (go/b/142967802).

PR Close #33257
2019-10-18 19:48:03 -04:00
Judy Bogart 8d44b5edac docs: edit and organize language service doc (#33202)
PR Close #33202
2019-10-18 18:19:05 -04:00
Kara Erickson f289411fa9 docs(core): add migration guide links to schematics (#33258)
Angular v9 schematics should print out a link to the migration
guide associated with each schematic. This way, users have an
easy way to find more information about the automatic code
transformations they will see with `ng update`.

PR Close #33258
2019-10-18 18:18:37 -04:00
Kapunahele Wong 32b042014d docs: add field decorators to undecorated classes migration (#33069)
PR Close #33069
2019-10-18 16:31:10 -04:00
Kapunahele Wong 940fbbb014 docs: add localize migration doc (#33086)
PR Close #33086
2019-10-18 16:30:39 -04:00
crisbeto 1799f621b7 refactor(core): deprecate entryComponents (#33205)
With Ivy the `entryComponents` array isn't necessary anymore. These changes mark it as deprecated so that it can be removed in a future version.

PR Close #33205
2019-10-18 16:29:23 -04:00
Matias Niemelä cb4f803238 release: cut the v9.0.0-next.12 release 2019-10-18 13:04:25 -07:00
crisbeto 0e08ad628a fix(ivy): throw better error for missing generic type in ModuleWithProviders (#33187)
Currently if a `ModuleWithProviders` is missng its generic type, we throw a cryptic error like:

```
error TS-991010: Value at position 3 in the NgModule.imports of TodosModule is not a reference: [object Object]
```

These changes add a better error to make it easier to debug.

PR Close #33187
2019-10-18 14:49:54 -04:00
Suguru Inatomi e0059c7d51 refactor: format files (#31248)
PR Close #31248
2019-10-18 14:49:12 -04:00
Suguru Inatomi e122d27176 refactor: fix by beedback (#31248)
PR Close #31248
2019-10-18 14:49:12 -04:00
Suguru Inatomi bab740d793 refactor: format files (#31248)
PR Close #31248
2019-10-18 14:49:12 -04:00
Suguru Inatomi 60e4490808 refactor: fix by feedback (#31248)
PR Close #31248
2019-10-18 14:49:12 -04:00
Suguru Inatomi 251a512222 refactor: create CompletionKind.PSEUDO_ELEMENT (#31248)
PR Close #31248
2019-10-18 14:49:12 -04:00
Suguru Inatomi 692535a935 refactor: make pseudo elements array readonly (#31248)
PR Close #31248
2019-10-18 14:49:12 -04:00
Suguru Inatomi 7c64b8d3fd feat(language-service): add Angular pseudo elements into completions (#31248)
PR Close #31248
2019-10-18 14:49:12 -04:00
ayazhafiz c44a1a78a9 docs: add ayaz hafiz as a contributor (#32975)
PR Close #32975
2019-10-18 14:43:13 -04:00
Alison Gale f6667f8281 fix(router): adjust UrlTree redirect to replace URL if in eager update (#32988)
Resubmit #31168 now that google3 tests can pass. This requires http://cl/272696717 to be patched.
Original description from jasonaden:

Without this change when using UrlTree redirects in urlUpdateStrategy="eager", the URL would get
updated to the target location, then redirected. This resulted in having an additional entry in the
history and thus the back button would be broken (going back would land on the URL causing a new
redirect).

Additionally, there was a bug where the redirect, even without urlUpdateStrategy="eager", could
create a history with too many entries. This was due to kicking off a new navigation within the
navigation cancelling logic. With this PR the new navigation is pushed to the next tick with a
setTimeout, allowing the page being redirected from to be cancelled before starting a new
navigation.

Related to #27148

fix(router): adjust UrlTree redirect to replace URL if in eager update

Fix lint errors

PR Close #32988
2019-10-18 14:42:21 -04:00
JoostK 6958d11d95 feat(ivy): type checking of event bindings (#33125)
Until now, the template type checker has not checked any of the event
bindings that could be present on an element, for example

```
<my-cmp
  (changed)="handleChange($event)"
  (click)="handleClick($event)"></my-cmp>
```

has two event bindings: the `change` event corresponding with an
`@Output()` on the `my-cmp` component and the `click` DOM event.

This commit adds functionality to the template type checker in order to
type check both kind of event bindings. This means that the correctness
of the bindings expressions, as well as the type of the `$event`
variable will now be taken into account during template type checking.

Resolves FW-1598

PR Close #33125
2019-10-18 14:41:53 -04:00