develwoutacause’s avatardevelwoutacause’s Twitter Archive—№ 1,699

  1. …in reply to @justinfagnani
    @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; }
    1. …in reply to @develwoutacause
      @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 setting public shadowRoot!: ShadowRoot; stackblitz.com/edit/typescript-gd8pn1?file=index.html,tsconfig.json
      1. …in reply to @develwoutacause
        @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.
        1. …in reply to @develwoutacause
          @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'
          1. …in reply to @develwoutacause
            @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.