angular-docs-cn/packages/compiler/src/aot
Keen Yee Liau fd51e01335 fix(compiler): Metadata should not include methods on Object.prototype (#38292)
This commit fixes a bug in View Engine whereby the compiler errorneously
thinks that a method of a component has decorator metadata when that
method is one of those in `Object.prototype`, for example `toString`.

This bug is discovered in v10.0.4 of `@angular/language-service` after
the default bundle format was switched from ES5 to ES2015.

ES5 output:
```js
if (propMetadata[propName]) {
    decorators.push.apply(decorators, __spread(propMetadata[propName]));
}
```

ES2015 output:
```js
if (propMetadata[propName]) {
    decorators.push(...propMetadata[propName]);
}
```

The bug was not discovered in ES5 because the polyfill for the spread
operator happily accepts parameters that do not have the `iterable`
symbol:

```js
function __spread() {
    for (var ar = [], i = 0; i < arguments.length; i++)
        ar = ar.concat(__read(arguments[i]));
    return ar;
}
```

whereas in es2015 it’ll fail since the iterable symbol is not present in
`propMetadata['toString']` which evaluates to a function.

Fixes https://github.com/angular/vscode-ng-language-service/issues/859

PR Close #38292
2020-07-30 15:18:28 -07:00
..
compiler.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
compiler_factory.ts refactor(compiler): remove extra imports (#37246) 2020-06-11 19:00:33 -07:00
compiler_host.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
compiler_options.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
formatted_error.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
generated_file.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
lazy_routes.ts refactor(compiler): remove extra imports (#37246) 2020-06-11 19:00:33 -07:00
partial_module.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
static_reflector.ts fix(compiler): Metadata should not include methods on Object.prototype (#38292) 2020-07-30 15:18:28 -07:00
static_symbol.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
static_symbol_resolver.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
summary_resolver.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
summary_serializer.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
util.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00