angular/packages
George Kalpakas af4fe3aa4e fix(ngcc): correctly detect emitted TS helpers in ES5 (#35191)
In ES5 code, TypeScript requires certain helpers (such as
`__spreadArrays()`) to be able to support ES2015+ features. These
helpers can be either imported from `tslib` (by setting the
`importHelpers` TS compiler option to `true`) or emitted inline (by
setting the `importHelpers` and `noEmitHelpers` TS compiler options to
`false`, which is the default value for both).

Ngtsc's `StaticInterpreter` (which is also used during ngcc processing)
is able to statically evaluate some of these helpers (currently
`__assign()`, `__spread()` and `__spreadArrays()`), as long as
`ReflectionHost#getDefinitionOfFunction()` correctly detects the
declaration of the helper. For this to happen, the left-hand side of the
corresponding call expression (i.e. `__spread(...)` or
`tslib.__spread(...)`) must be evaluated as a function declaration for
`getDefinitionOfFunction()` to be called with.

In the case of imported helpers, the `tslib.__someHelper` expression was
resolved to a function declaration of the form
`export declare function __someHelper(...args: any[][]): any[];`, which
allows `getDefinitionOfFunction()` to correctly map it to a TS helper.

In contrast, in the case of emitted helpers (and regardless of the
module format: `CommonJS`, `ESNext`, `UMD`, etc.)), the `__someHelper`
identifier was resolved to a variable declaration of the form
`var __someHelper = (this && this.__someHelper) || function () { ... }`,
which upon further evaluation was categorized as a `DynamicValue`
(prohibiting further evaluation by the `getDefinitionOfFunction()`).

As a result of the above, emitted TypeScript helpers were not evaluated
in ES5 code.

---
This commit changes the detection of TS helpers to leverage the existing
`KnownFn` feature (previously only used for built-in functions).
`Esm5ReflectionHost` is changed to always return `KnownDeclaration`s for
TS helpers, both imported (`getExportsOfModule()`) as well as emitted
(`getDeclarationOfIdentifier()`).

Similar changes are made to `CommonJsReflectionHost` and
`UmdReflectionHost`.

The `KnownDeclaration`s are then mapped to `KnownFn`s in
`StaticInterpreter`, allowing it to statically evaluate call expressions
involving any kind of TS helpers.

Jira issue: https://angular-team.atlassian.net/browse/FW-1689

PR Close #35191
2020-02-21 09:06:47 -08:00
..
animations fix(animations): false positive when detecting Node in Webpack builds (#35134) 2020-02-20 10:51:16 -08:00
bazel build: update to bazel_toolchains 2.1.0 (#35430) 2020-02-13 16:29:34 -08:00
benchpress build: derive ts_library dep from jasmine_node_test boostrap label if it ends in _es5 (#34736) 2020-01-15 14:58:09 -05:00
common test(common): unit test for http/testing expectOne with several requests (#27005) 2020-01-31 13:13:39 -08:00
compiler fix(ivy): incorrectly generating shared pure function between null and object literal (#35481) 2020-02-20 15:23:59 -08:00
compiler-cli fix(ngcc): correctly detect emitted TS helpers in ES5 (#35191) 2020-02-21 09:06:47 -08:00
core fix(ivy): incorrectly generating shared pure function between null and object literal (#35481) 2020-02-20 15:23:59 -08:00
docs refactor(core): remove deprecated Renderer (#33019) 2019-10-08 09:23:00 -07:00
elements fix(elements): schematics fails with schema.json not found error (#35211) 2020-02-11 11:42:52 -08:00
examples docs: changes AoT to AOT for consistency (#35112) 2020-02-04 10:43:34 -08:00
forms docs(forms): remove outdated ngForm selector deprecation notice (#35435) 2020-02-14 15:34:01 -08:00
http refactor(http): fix a strictBindCallApply issue. (#34817) (#34960) 2020-01-24 15:55:11 -08:00
language-service fix(language-service): Suggest ? and ! operator on nullable receiver (#35200) 2020-02-10 16:43:46 -08:00
localize fix(localize): support minified ES5 $localize calls (#35562) 2020-02-20 10:55:54 -08:00
platform-browser fix(ivy): set namespace for host elements of dynamically created components (#35136) 2020-02-07 17:22:54 -08:00
platform-browser-dynamic refactor(core): order private exports alphabetically (#35003) 2020-01-28 15:57:58 -08:00
platform-server fix(ivy): set namespace for host elements of dynamically created components (#35136) 2020-02-07 17:22:54 -08:00
platform-webworker build: derive ts_library dep from jasmine_node_test boostrap label if it ends in _es5 (#34736) 2020-01-15 14:58:09 -05:00
platform-webworker-dynamic build: set up all packages to publish via wombot proxy (#33747) 2019-11-13 11:34:33 -08:00
private/testing build: migrate determining if Ivy is enabled in typescript genrule files to use angular_ivy_enabled (#33983) 2019-11-26 16:38:41 -05:00
router test: setup circular dependency tests for all entry points (#34774) 2020-01-23 11:36:41 -08:00
service-worker test: setup circular dependency tests for all entry points (#34774) 2020-01-23 11:36:41 -08:00
upgrade docs: changes AoT to AOT for consistency (#35112) 2020-02-04 10:43:34 -08:00
zone.js feat: add an tickOptions parameter with property processNewMacroTasksSynchronously. (#33838) 2020-02-20 15:15:00 -08:00
BUILD.bazel build: reference zone.js from source directly instead of npm. (#33046) 2019-11-06 00:48:34 +00:00
empty.ts
goog.d.ts fix(ivy): use goog.LOCALE for Closure Compiler to define default LOCALE_ID (#31519) 2019-07-16 13:02:10 -04:00
license-banner.txt build: bump year (#34651) 2020-01-13 07:21:43 -08:00
README.md docs: add doc reference to npm package readme (#33911) 2019-11-20 14:46:23 -08:00
system.d.ts
tsconfig-build-no-strict.json refactor(core): ensure compatibility with typescript strict flag (#30993) 2019-07-18 14:21:25 -07:00
tsconfig-build.json refactor(core): ensure compatibility with typescript strict flag (#30993) 2019-07-18 14:21:25 -07:00
tsconfig-test.json refactor: fix typescript strict flag failures in all tests (#30993) 2019-07-18 14:21:26 -07:00
tsconfig.json build: consolidate @angular-devkit/build-angular to the root package.json (#34002) 2019-12-02 10:49:13 -08:00
types.d.ts build: reference zone.js from source directly instead of npm. (#33046) 2019-11-06 00:48:34 +00:00

Angular

The sources for this package are in the main Angular repo. Please file issues and pull requests against that repo.

Usage information and reference details can be found in Angular documentation.

License: MIT