refactor(elements): add accessor workaround for build-optimizer (#37456)

Build-optimizer currently uses TypeScript 3.6 which is unable to resolve an 'accessor' in 'getTypeOfVariableOrParameterOrPropertyWorker'.

Unfortunately, in Build optimizer we cannot update the version of TypeScript because of https://github.com/microsoft/TypeScript/issues/38412

PR Close #37456
This commit is contained in:
Alan Agius 2020-06-08 13:27:50 +02:00 committed by Misko Hevery
parent aa8f1d569b
commit a937889c3b
1 changed files with 5 additions and 1 deletions

View File

@ -213,7 +213,11 @@ export function createCustomElement<P>(
// compliance with the spec). This breaks emulated inheritance in ES5 on environments that do not
// natively support `Object.setPrototypeOf()` (such as IE 9-10).
// Update the property descriptor of `NgElementImpl#ngElementStrategy` to make it enumerable.
Object.defineProperty(NgElementImpl.prototype, 'ngElementStrategy', {enumerable: true});
// The below 'const', shouldn't be needed but currently this breaks build-optimizer
// Build-optimizer currently uses TypeScript 3.6 which is unable to resolve an 'accessor'
// in 'getTypeOfVariableOrParameterOrPropertyWorker'.
const getterName = 'ngElementStrategy';
Object.defineProperty(NgElementImpl.prototype, getterName, {enumerable: true});
// Add getters and setters to the prototype for each property input.
defineInputGettersSetters(inputs, NgElementImpl.prototype);