Commit Graph

17947 Commits

Author SHA1 Message Date
Andrew Kushnir 42a9e5ad7d ci: increase payload size limits for integration tests (#37123)
This commit updates payload size limits that are triggering errors after merging cda2530. That commit seems to contribute to the payload size increase, but all checks were "green" for the original PR (#35889), so it looks like it's an accumulated payload size increase from multiple changes. The goal of this commit is to bring the master branch back to "green" state.

PR Close #37123
2020-05-14 17:35:26 -07:00
Miško Hevery cda2530df5 fix(core): Host classes should not be fed back into `@Input` (#35889)
Previously all static styling information (including the ones from component/directive host bindings) would get merged into a single value before it would be written into the `@Input('class'/'style')`. The new behavior specifically excludes host values from the `@Input` bindings.

Fix #35383

PR Close #35889
2020-05-14 15:54:13 -07:00
Andrew Scott aaa89bb715 refactor(core): rename refreshDynamicEmbeddedViews to refreshEmbeddedViews (#37117)
Dynamic embedded views were conceptually different from inline embedded views, but we have since
removed the inline embedded views so we now only have "embedded views".
See related refactoring work to remove inline embedded views in #34715
and #37073.

PR Close #37117
2020-05-14 15:50:52 -07:00
Daniel Seibel Silva ea971f7098 fix(core): inheritance delegate ctor regex updated to work on minified code (#36962)
If one component Parent inherit another component Base like the following:

@Component(...)
class Base {
  constructor(@Inject(InjectionToken) injector: Injector) { }
}

@Component(...)
class Parent extends Base {
    // no constructor
}

When creating Component Parent, the dependency injection should work on delegating ctors like above.

The code Parent code above will be compiled into something like:

class Parent extends Base {
  constructor() {
    super(...arguments);
  }
}

The angular core isDelegateCtor function will identify the delegation ctor to the base class.

But when the code above is minified (using terser), the minified code will compress the spaces, resulting in something like:
class Parent extends Base{constructor(){super(...arguments)}}

The regex will stop working, since it wasn't aware of this case. So this fix will allow this to work in minified code cases.

PR Close #36962
2020-05-14 15:49:46 -07:00
pkozlowski-opensource ddaa124162 refactor(core): remove _tViewNode field from ViewRef (#36814)
The _tViewNode field (that was marked as internal) on the ViewRef is not
necessery as a reference to a relevant TView is available as a local
variable.

PR Close #36814
2020-05-14 15:35:37 -07:00
Andrew Kushnir 7a30153aa1 test(core): verify that Ivy i18n works correctly with HTML namespaces (#36943)
This commit adds several tests to verify that i18n logic in Ivy handles elements with HTML namespaces correctly.

Related to #36941.

PR Close #36943
2020-05-14 15:20:42 -07:00
Joey Perrott 7acd33007d fix(dev-infra): do not require a commit body for release commits (#37110)
Release commits do not require a commit body as the context, usually
provided in commit body, is already available in the process of
releasing.  No additional value is gained from adding a body message
on these commits.

PR Close #37110
2020-05-14 13:03:34 -07:00
Andrew Scott 8a56c99f87 docs(router): Update router guide to use UrlTree for guard redirects (#37100)
The current implementation for redirecting users inside guards was in place
before the feature was added to allow `CanActivate` and `CanActivateChild` guards
to return `UrlTree` for redirecting users.

Returning `UrlTree` should be the default method, as it provides a more desirable
redirecting experience. When using `router.navigate` followed by `return false`,
the `Router` calls `resetUrlToCurrentUrlTree` (in the `finalize` operator) before
processing the navigation to the new route.  This can result in an undesirable
history if the navigation was the first navigation in the application - that is,
the route will briefly be reset to just `/` (see #36187).

Fixes #36187

PR Close #37100
2020-05-14 12:23:35 -07:00
Santosh Yadav 77c0ef38be docs(router): filter the event to subscribe (#37027)
The current code will not work as the `e` will be an event,
If we try to access e.id and e.url it will throw an exception, the correct way is to use map or filter down to specific events

PR Close #37027
2020-05-14 12:01:46 -07:00
Sonu Kapoor 5f64e52ed4 docs: clarifies the service limitation (#36349)
Closes #36332

PR Close #36349
2020-05-14 11:59:44 -07:00
cexbrayat b2a3325258 docs: remove the note about @angular/http from the deprecations guide (#37070)
This was originally pushed by @igorminar in #36944, but later reverted in #35621
This commit reintroduces the original changes, and remove the `@angular/http` secion from the deprecations guide.

PR Close #37070
2020-05-14 11:01:18 -07:00
Andrew Scott 95f429c7e2 refactor(dev-infra): add atscott for fw-core approvers (#37020)
Add atscott (Andrew Scott) to the list of approvers in the fw-core section of the .pullapprove.yml file.

PR Close #37020
2020-05-14 11:00:20 -07:00
Pete Bacon Darwin f16ca1ce46 build(docs-infra): correctly handle "pseudo" classes (#36989)
In the code base there are cases where there is, conceptually, a class
that is represented by a combination of an `interface`
(type declaration) and a `const` (value declaration).

For example:

```
export interface SomeClass {
  count(a?: string): number;
}
export const: SomeClass = class {
  someMethod(a: string = ''): number { ... }
};
```

These were being rendered as interfaces and also not
correctly showing the descriptions and default parameter
values.

In this commit such concepts are now rendered as classes.
The classes that are affected by this are:

* `DebugElement`
* `DebugNode`
* `Type`
* `EventEmitter`
* `TestBed`

Note that while decorators are also defined in this form
they have their own rendering type (`decorator`) and so
are not affecte by this.

PR Close #36989
2020-05-14 10:50:30 -07:00
Alan Agius 508c555ce2 test: update language service module resolution cache (#36989)
With this change we update the expect of the `module resolution cache` were in the second count with cache the `fileExists` is called less then 700 times.

PR Close #36989
2020-05-14 10:50:30 -07:00
Alan Agius f97d8a9cbd refactor: `EventEmitter` to retain behaviour of pre TypeScript 3.9 (#36989)
TypeScript 3.9 introduced a breaking change where extends `any` no longer acts as `any`, instead it acts as `unknown`.

With this change we retain the behavior we had with TS 3.8 which is;

When using the `EventEmitter` as a type you must always provide a  type;
```ts
let emitter: EventEmitter<string>
```

and when initializing the `EventEmitter` class you can either provide a  type or or use the fallback type which is `any`

```ts
const emitter = new EventEmitter(); // EventEmitter<any>
const emitter = new EventEmitte<string>(); // EventEmitter<string>
``

PR Close #36989
2020-05-14 10:50:30 -07:00
Alan Agius 24ec5235a0 test: disable `cli-hello-world-lazy-rollup` from ivy tests (#36989)
`cli-hello-world-lazy-rollup` fails on a bundle size check because Ivy and VE main-es2015 sizes are different

PR Close #36989
2020-05-14 10:50:30 -07:00
Alan Agius bbd556ee9f test: enable importHelpers for UMD builds (#36989)
This is a workaround for a TS 3.9 regression https://github.com/microsoft/TypeScript/issues/38501 where the emitted `__exportStar` helpers have a missing semi-colon at the end of the unnamed function, when targetting UMD, and causes the following runtime error `Uncaught TypeError: (intermediate value)(…) is not a function`.

This is because the anonymous `__exportStar` function will be invoked with the function on the next like as the parameter which is subsequently invoking whatever was returned.

To get around this TS bug, add `importHelpers: true` in your tsconfig. This also, is recommanded to avoid multiple copies of the same helper being inlined, which might cause increase in bundle size.

PR Close #36989
2020-05-14 10:50:30 -07:00
Alan Agius 466df41c8f test: update payload sizes after TS 3.9 update (#36989)
With this changer we update the CLI size-tracking changes for uncompressed
main-es2015 file. This file is larger due to new emitted shape of
ES2015 classes in TypeScript 3.9, which are now wrapped in IIFE.

PR Close #36989
2020-05-14 10:50:30 -07:00
Pete Bacon Darwin 4e1b5e43fa fix(compiler-cli): compute the correct target output for `$localize` messages (#36989)
In some versions of TypeScript, the transformation of synthetic
`$localize` tagged template literals is broken.
See https://github.com/microsoft/TypeScript/issues/38485

We now compute what the expected final output target of the
compilation will be so that we can generate ES5 compliant
`$localize` calls instead of relying upon TS to do the downleveling
for us.

This is a workaround for the TS compiler bug, which could be removed
when this is fixed. But since it only affects ES5 targeted compilations,
which is now not the norm, it has limited impact on the majority of
Angular projects. So this fix can probably be left in indefinitely.

PR Close #36989
2020-05-14 10:50:30 -07:00
Pete Bacon Darwin b0e362f75b test(docs-infra): update payload sizes after TS 3.9 update (#36989)
Here are the significant changes found in
`dist/main.js` for AIO...

```
t.\u0275prov = r.Kb({token: t, factory: t.\u0275fac}),
```
to
```
t.\u0275prov = r.Jb({
  token: t,
  factory: function(e) {
    return t.\u0275fac(e)
  }
}),
```

```
function hs(t){const e=ms();
```

to

```
  function fs(t){if(!(t=String(t).trim()))return'';
  const e=t.match(ds);
  return e&&Un(e[1])===e[1]||t.match(hs)&&function(t){let e=!0,n=!0;
  for(let s=0;
  s<t.length;
  s++){const r=t.charAt(s);
  '\''===r&&n?e=!e:'"'===r&&e&&(n=!n)}return e&&n}(t)?t:(Hn()&&console.warn(`WARNING: sanitizing unsafe style value ${t} (see http://g.co/ng/security#xss).`),'unsafe')}function ps(t){const e=ys();
```

```
b=Kt(p[1],0),
e&&(b.projection=e.map(t=>Array.from(t))),
```

to

```
if(b=Kt(f,0),void 0!==e){const t=b.projection=[];
for(let n=0; n<this.ngContentSelectors.length; n++){
  const s=e[n];
  t.push(null!=s?Array.from(s):null)
}
```

```
return o.observedAttributes=Object.keys(i),
n.map(({propName:t})=>t)
    .forEach(t=>{
      Object.defineProperty(o.prototype,t,{ ... })
}),o}
```

to

```
return t.observedAttributes=Object.keys(i),t})();
return n.map(({propName:t})=>t)
    .forEach(t=>{
      Object.defineProperty(o.prototype,t,{ ... })
    }),o}
```

PR Close #36989
2020-05-14 10:50:30 -07:00
Pete Bacon Darwin 91092f668e fix(ngcc): support `defineProperty()` re-exports in CommonJS and UMD (#36989)
In TypeScript 3.9 some re-export syntaxes have changed to be getter
functions (created by calls to `Object.defineProperty()`) rather than
simple property accessors.

This commit adds support into the CommonJS and UMD reflection hosts
for this style of re-export syntax.

PR Close #36989
2020-05-14 10:50:29 -07:00
Pete Bacon Darwin d268d2ad85 fix(ngcc): `viaModule` should be `null` for local imports (#36989)
In the CommonJS and UMD reflection hosts, the logic for computing the
`viaModule` property of `Declaration` objects was not correct for some
cases when getting the exports of modules.

In these cases it was setting `viaModule` to the path of the local module
rather than `null`.

PR Close #36989
2020-05-14 10:50:29 -07:00
Pete Bacon Darwin 2486db7c2b docs(ngcc): tidy up typos etc in comments (#36989)
This file had a few small typos and other issues that have
now been fixed in this commit.............................

PR Close #36989
2020-05-14 10:50:29 -07:00
Pete Bacon Darwin 0672a0e547 refactor(ngcc): rename `ReexportStatement` to `WildcardReexportStatement` (#36989)
The term `ReexportStatement` is too general for this particular concept.
Here the re-export actually refers to a wildcard where all the module
exports are being re-exported.

When we introduce other re-export statement types later this will be
confusing.

PR Close #36989
2020-05-14 10:50:29 -07:00
Pete Bacon Darwin 9846b19986 test(ngcc): reformat some subject code for tests (#36989)
Using backtick multiline strings leads to confusing layout
that does not fit with the surrounding indentation. Also it
can lead to test fragility due to automated code formatting.

This commit changes just one set of subject code to use
a more resilient string concatenation approach.

PR Close #36989
2020-05-14 10:50:29 -07:00
Pete Bacon Darwin 8b79075497 test(compiler-cli): hande TS 3.9 format in emisson tests (#36989)
In TypeScript 3.9 the emitted JS code has some differences.
This commit updates the tests to be resilient to these changes.

PR Close #36989
2020-05-14 10:50:29 -07:00
Pete Bacon Darwin 2956f21d82 test(ngcc): move specs to correct describe block (#36989)
The recent tests for Enum handling were added to the
incorrect describe block. This commit moves them back
to the correct block.

PR Close #36989
2020-05-14 10:50:29 -07:00
Pete Bacon Darwin c8ee390d23 fix(ngcc): ensure rendering formatters work with IIFE wrapped classes (#36989)
After the refactoring of the reflection hosts to accommodate
ES2015 classes wrapped in IIFEs. The same treatment needs to
be applied to the rendering formatters.

PR Close #36989
2020-05-14 10:50:29 -07:00
Pete Bacon Darwin d7440c452a fix(ngcc): ensure reflection hosts can handle TS 3.9 IIFE wrapped classes (#36989)
In TS 3.9, ES2015 output can contain ES classes that are wrapped in an
IIFE. So now ES2015 class declarations can look like one of:

```
class OuterClass1 {}
```

```
let OuterClass = class InnerClass {};
```

```
var AliasClass;
let OuterClass = AliasClass = class InnerClass {};
```

```
let OuterClass = (() => class InnerClass {}};
```

```
var AliasClass;
let OuterClass = AliasClass = (() => class InnerClass {})();
```

```
let OuterClass = (() => {
  let AdjacentClass = class InnerClass {};
  // ... static properties or decorators attached to `AdjacentClass`
  return AdjacentClass;
})();
```

```
var AliasClass;
let OuterClass = AliasClass = (() => {
  let AdjacentClass = class InnerClass {};
  // ... static properties or decorators attached to `AdjacentClass`
  return AdjacentClass;
})();
```

The `Esm5ReflectionHost` already handles slightly different IIFE wrappers
around function-based classes. This can be substantially reused when
fixing `Esm2015ReflectionHost`, since there is a lot of commonality
between the two.

This commit moves code from the `Esm5ReflectionHost` into the `Esm2015ReflectionHost`
and looks to share as much as possible between the two hosts.

PR Close #36989
2020-05-14 10:50:29 -07:00
Pete Bacon Darwin a2b8dc1cfb refactor(ngcc): ensure unlocker process works in mock file-systems (#36989)
Previously the path to the unlocker process was being resolved by the
current file-system. In the case that this was a `MockFileSystemWindows`
on a non-Windows operating system, this resulted in an incorrect path
to the entry-point.

Now the path to the entry-point is hand-crafted to avoid being broken by
whatever FileSystem is in use.

PR Close #36989
2020-05-14 10:50:28 -07:00
Pete Bacon Darwin 7ebf35c5f8 refactor(ngcc): remove unused import (#36989)
The `Import` import from `src/ngtsc/reflection` is not being used.
This commit simply removes this import from the code.

PR Close #36989
2020-05-14 10:50:28 -07:00
Pete Bacon Darwin dbcaf22805 refactor(compiler-cli): delegate `hasBaseClass()` to `getBaseClassExpression()` (#36989)
The previous implementations of `hasBaseClass()` are almost
identical to the implementation of `getBaseClassExpression()`.
There is little benefit in duplicating this code so this refactoring
changes `hasBaseClass()` to just call `getBaseClassExpression()`.
This allows the various hosts that implement this to be simplified.

PR Close #36989
2020-05-14 10:50:28 -07:00
Pete Bacon Darwin 0066a1ae70 refactor(compiler-cli): simplify and clarify `TypeScriptReflectionHost.isClass()` (#36989)
The comment in this function confused me, so I updated it to clarify that
`isClass()` is not true for un-named classes.

Also, I took the opportunity to use a helper method to simplify the function
itself.

PR Close #36989
2020-05-14 10:50:28 -07:00
Pete Bacon Darwin 491da99abe refactor(ngcc): simplify the `detectKnownDeclaration()` signature (#36989)
A number of overloads were added to `detectKnownDeclaration()` to
allow it to support `null` being passed through. In practice this could
easily be avoided, which allows the overloads to be removed and the
method signature and implementations to be simplified.

PR Close #36989
2020-05-14 10:50:28 -07:00
Alan Agius 13ba84731f build: prepare for TypeScript 3.9 (#36989)
- Fix several compilation errors
- Update @microsoft/api-extractor to be compatible with TypeScript 3.9

PR Close #36989
2020-05-14 10:50:28 -07:00
Keen Yee Liau b58bd2bb91 test(language-service): external template update should not invalidate program (#36989)
In TypeScript 3.9, the compiler is able to re-use (i.e. not invalidate)
the previous program if only external templates (i.e. no TS files) have
changed.

PR Close #36989
2020-05-14 10:50:27 -07:00
Keen Yee Liau a32cbed89c fix(language-service): use empty statement as parent of type node (#36989)
In TypeScript 3.9, type nodes need to exist in the context of a statement.
This commit ensures that the synthetic type node has such a parent.

PR Close #36989
2020-05-14 10:50:27 -07:00
Alan Agius c42f35eb2f build: pin @microsoft/api-extractor to 7.7.11 (#36989)
Version 7.7.12 generates aliases for objects named the same as global symbols which breaks ts-api-guardian since it doesn't support aliases.

See: https://github.com/microsoft/rushstack/issues/1830

PR Close #36989
2020-05-14 10:50:27 -07:00
Sonu Kapoor 2418c6aca1 refactor(docs-infra): refactors `addImageDimensionsImpl` (#37046)
This commit changes the `addImageDimensionsImpl` method to reduce
nesting. It will exit early, if the conditions are not matched.

PR Close #37046
2020-05-14 10:48:01 -07:00
Shadi Namrouti 90205079d7 docs(common): English grammar (#36908)
In English grammar, the comma followed by a conjunction is considered incorrect. This kind of mistakes called comma splice.
See: https://www.grammarly.com/blog/comma-splice/
PR Close #36908
2020-05-13 16:03:25 -07:00
Paul Gschwendtner 57a868627f test(docs-infra): re-enable upgrade-phonecat-2-hybrid example e2e tests (#36969)
We recently disabled the e2e tests for `upgrade-phonecat-2-hybdrid`
because the switch to APF 10 caused it to fail with an uglify
error. More details in a dedicated issue here:

https://github.com/angular/angular/issues/36957.

We can re-enable the test by switching to Terser that properly
handles ES2015 syntax. Previously the rollup bundle consisted
only of ES5 output as the Angular framework packages provided
ES5 output. With APF 10, there is no ES5 output except for the
non-optimizable UMD format.

Hence we either need to downlevel code to ES5, or use Terser
that supports ES2015 syntax.

Closes #36957.

PR Close #36969
2020-05-13 16:02:29 -07:00
Judy Bogart 2cacab92e6 docs: correct typos in doc for template type guards (#37090)
correct some small typos in new feature recommendation in stuctural-directives.md and reference from aot-compiler.md

PR Close #37090
2020-05-13 16:01:20 -07:00
Kara Erickson 0520ecb7d0 docs: add Cindy to contributors (#37076)
Cindy has been working with us for a while now
and should be listed on AIO as a part of our team.
This commit adds her image / bio to the Angular
contributors page.

PR Close #37076
2020-05-13 16:01:00 -07:00
Andrew Scott 047642556c refactor(core): remove ActiveIndexFlag from LContainer (#37073)
The ActiveIndexFlag is no longer needed because we no longer have "inline embedded views".
There is only one type of embedded view so we do not need complex tracking for
inline embedded views.

HAS_TRANSPLANTED_VIEWS now takes the place of the ACTIVE_INDEX slot as a
simple boolean rather than being a shifted flag inside the ACTIVE_INDEX bits.

PR Close #37073
2020-05-13 16:00:41 -07:00
Adam Plumer 9edea0bb75 feat(platform-server): use absolute URLs from Location for HTTP (#37071)
Currently, requests from the server that do not use absolute URLs
fail because the server does not have the same fallback mechanism
that browser XHR does. This adds that mechanism by pulling the
full URL out of the document.location object, if available.

PR Close #37071
2020-05-13 16:00:02 -07:00
Sonu Kapoor ce39755937 docs: Remove duplicate `and` (#37067)
This commit removes the duplicate `and` found in the
`Support for the development cycle` section part of the
getting started guide.

Fixes #37060

PR Close #37067
2020-05-13 15:59:41 -07:00
Joey Perrott 7d3f5043e1 build: fix assumed aliases in rebase-pr script (#37050)
The local rebase-pr script assumes the existence of specific git
aliases.  Instead this script should rely on the full written out
command instead.

PR Close #37050
2020-05-13 15:59:19 -07:00
Joey Perrott 14c0ec97d8 feat(dev-infra): introduce validators for ng-dev config loading (#37049)
Introduces infrastructure to validate configuration of the ng-dev
command at run time.  Allowing for errors to be returned to the
user running the command.

PR Close #37049
2020-05-13 15:58:46 -07:00
Matias Niemelä 45f4a47286 refactor(core): remove style sanitization code for `[style]`/`[style.prop]` bindings (#36965)
In 420b9be1c1 all style-based sanitization code was
disabled because modern browsers no longer allow for javascript expressions within
CSS. This patch is a follow-up patch which removes all traces of style sanitization
code (both instructions and runtime logic) for the `[style]` and `[style.prop]` bindings.

PR Close #36965
2020-05-13 15:56:12 -07:00
Pete Bacon Darwin 141fcb95a4 refactor(localize): use the `FileSystem` from ngtsc (#36843)
This commit makes the leap from its own custom baked `FileUtils`
solution to the fully formed `FileSystem` that is used in the compiler-cli.

This makes testing more straightforward and helps to ensure that the tool
will work across operatings systems.

Also, going forward, it will allow the localize project access to other useful
code from the compiler-cli, such as source-map handling.

PR Close #36843
2020-05-13 15:52:48 -07:00