-
@justinfagnani @WestbrookJ Thanks @WestbrookJ and @justinfagnani! I was confused about your step 6) given that it's the non-defined property that's broken. However, it seems that I was running #TypeScript on ESNext, which generates field declarations. class Foo { prop; }
-
@justinfagnani @WestbrookJ If I switch to
target: 'ES2020'
this property definition isn't generated and I can set values before upgrading the element. This also might explain some weird behavior I saw from settingpublic shadowRoot!: ShadowRoot;
stackblitz.com/edit/typescript-gd8pn1?file=index.html,tsconfig.json -
@justinfagnani @WestbrookJ So does this imply that
class Foo { prop; }
is equivalent to:class Foo { constructor() { this.prop = undefined; } }
I'm unclear on the reasoning for this behavior, though I get that most of the time it doesn't come up in practice.
-
@justinfagnani @WestbrookJ I tried reproducing outside of CE, but I can't manually invoke the constructor of a class. > class Foo { prop; } > Foo.apply({ prop: 'test' }); TypeError: Class constructor Foo cannot be invoked without 'new'
-
@justinfagnani @WestbrookJ This all seems incredibly nuanced and I'm struggling with what the best practice would be for this. 1. Use a CE library which restores props for you? 2. Always assign props after upgrading? 3. Don't use
target: 'ESNext / ES2022'
? All these options kinda suck.