Skip to content

Commit f2a32f7

Browse files
alan-agius4profanis
authored andcommitted
refactor(elements): add accessor workaround for build-optimizer (angular#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
1 parent 5e05784 commit f2a32f7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/elements/src/create-custom-element.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,11 @@ export function createCustomElement<P>(
213213
// compliance with the spec). This breaks emulated inheritance in ES5 on environments that do not
214214
// natively support `Object.setPrototypeOf()` (such as IE 9-10).
215215
// Update the property descriptor of `NgElementImpl#ngElementStrategy` to make it enumerable.
216-
Object.defineProperty(NgElementImpl.prototype, 'ngElementStrategy', {enumerable: true});
216+
// The below 'const', shouldn't be needed but currently this breaks build-optimizer
217+
// Build-optimizer currently uses TypeScript 3.6 which is unable to resolve an 'accessor'
218+
// in 'getTypeOfVariableOrParameterOrPropertyWorker'.
219+
const getterName = 'ngElementStrategy';
220+
Object.defineProperty(NgElementImpl.prototype, getterName, {enumerable: true});
217221

218222
// Add getters and setters to the prototype for each property input.
219223
defineInputGettersSetters(inputs, NgElementImpl.prototype);

0 commit comments

Comments
 (0)