Skip to content

[breaking change] Get rid of field initializers (and legacy decorators) #2288

@Kukkimonsuta

Description

@Kukkimonsuta

Enabling useDefineForClassFields in TypeScript will prevent decorators from working (both transpiled and using mobx.decorate).

This flag will be enabled by default for ESNext once class fields go stage 4: microsoft/TypeScript#34787

Possibly related to #1969

Intended outcome:

autorun using objectState is executed upon clicking on "increment" button.
autorun using classState is executed upon clicking on "increment" button.
autorun using classStateNoDecorator is executed upon clicking on "increment" button.

Actual outcome:

autorun using objectState is executed upon clicking on "increment" button.
⛔️ autorun using classState is NOT executed upon clicking on "increment" button.
⛔️ autorun using classStateNoDecorator is NOT executed upon clicking on "increment" button.

How to reproduce the issue:

https://codesandbox.io/s/fragrant-frog-x2487

Versions

TypeScript 3.7+
MobX - all tested versions (4.x, 5.x)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions