Skip to content

Commit

Permalink
refactor(elements): add accessor workaround for build-optimizer (angu…
Browse files Browse the repository at this point in the history
…lar#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 microsoft/TypeScript#38412

PR Close angular#37456
  • Loading branch information
alan-agius4 authored and ngwattcos committed Jun 25, 2020
1 parent 9125f99 commit ba74c71
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/elements/src/create-custom-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit ba74c71

Please sign in to comment.