Skip to content

Typescript 3.9 breaks getters in extendObservable #2386

@JabX

Description

@JabX

Typescript 3.9 introduced a sneaky breaking change regarding the way getter are emitted by setting enumerable: false instead of enumerable: true (associated PR here).

This causes extendObservable to ignore properties defined as getters in its second parameter, like that :

const obs = extendObservable({a: 2, b: 3}, { get c() { return a + b; });
obs.c // undefined (!!)

I'm a bit surprised that no one has yet reported this, it literally broke my entire app once I upgraded.

I'm not sure how this can be mitigated : how can extendObservable enumerate the properties to add if they aren't actually enumerable?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions