Skip to content
This repository has been archived by the owner on May 24, 2019. It is now read-only.

Attribute of class removed #75

Open
tcastelly opened this issue Nov 23, 2018 · 1 comment
Open

Attribute of class removed #75

tcastelly opened this issue Nov 23, 2018 · 1 comment
Labels

Comments

@tcastelly
Copy link

I'm using VueJS + FlowJS, when I remove types, attributes of class not initialized are removed too.
Unfortunately initialize variable is not possible here with VueJS because it come from a parent. So I can't rewrite it, there is an error at runtime.

e.g:

@Component
export default class UserDetails extends Vue {
  @Prop({ type: Number, required: true })
  id: number;
}

After flow-remove-types

@Component
export default class UserDetails extends Vue {
  @Prop({ type: Number, required: true })
}

That I expect:

@Component
export default class UserDetails extends Vue {
  @Prop({ type: Number, required: true })
  id;
}

Is there a solution ?
Thank you very much.

@motiz88
Copy link
Contributor

motiz88 commented Feb 15, 2019

We should be able to preserve uninitialised class fields in the output, but I worry that this will cause problems for people who may still be using the class field syntax purely for Flow typing purposes (e.g. still setting values in the constructor). V8 has just started to ship support for class fields, so it'll be a while before everyone is, say, using flow-node with a version of Node that has them.

Now, we could introduce this as a configurable flag, but it might be simpler to just use @babel/plugin-transform-strip-types in your case, since you're probably already compiling the decorator syntax (etc) with Babel.

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

No branches or pull requests

2 participants