Skip to content

Reactivity and undefined properties #211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
MayaRainer opened this issue Dec 20, 2017 · 4 comments
Closed

Reactivity and undefined properties #211

MayaRainer opened this issue Dec 20, 2017 · 4 comments

Comments

@MayaRainer
Copy link

In #35, a change was made where properties that are undefined will not become reactive. I feel like this change was overshooting its intentions a little, since the point is actually to get rid of uninitialized properties in the data object.
Considering that in a lot of coding standards the use of null is prohibited in favour of using undefined, it's a little problematic that null has to be used as a default value in class components.
I'm not sure whether there's a better way to fix this for Babel users, but as a TypeScript user, this change has honestly become quite inconvenient as every class component now needs to be littered with warning suppressions for the null keyword.
Any chance a better solution could be looked into here?

@ktsn
Copy link
Member

ktsn commented Dec 21, 2017

Unfortunately, we can't since the Babel decorator treats an uninitialized property and a property initialized with undefined as the same thing.
I encourage you to use data hook instead for now.

I'll revisit with this behavior after Babel and TypeScript implement stage 2 or later decorators.

@Glandos
Copy link

Glandos commented Mar 19, 2020

Hi @ktsn, it seems that it landed long time ago in babel/babel#7976 Apparently, the changelog mentioned only this:

Make Stage 2 decorators "default" (implementation is still WIP), and require people use the decoratorsLegacy option for easier migration.

But it has been there since nearly 2 years now.
Is there anything left missing to make undefined data being reactive again?

@ktsn
Copy link
Member

ktsn commented Mar 19, 2020

Because TypeScript does not support stage 2 yet.

@msklvsk
Copy link

msklvsk commented Dec 4, 2020

For anyone who’s wondering: TypeScript still does not support stage 2:

image

Not even planned for November.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants