How can I refactor a field into the constructor?

I can only see the "Indroduce field..." QuickFix, but this does not move the field into the constructor.

0
3 comments

There is a Convert field to parameter property intention (available on Alt+Enter) that changes

class Foo {
constructor(field: string) {
this.field = field;
}
field: string
}

to

class Foo {
constructor(public field: string) {
}
}

0

I need a Quickfix (in Webstorm)

to get from this



class Foo {
do() {
bar.do2();
}
}


// to this


class Foo {
constructor(public bar:any){}
do() {
this.bar.do2()
}
}

Is that possible?

0

No, there is no such quickfix

0

Please sign in to leave a comment.