Skip to content
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

fix: avoid breakage by not to auto augment hooks type #386

Merged
merged 2 commits into from
Jan 12, 2020
Merged

Conversation

ktsn
Copy link
Member

@ktsn ktsn commented Jan 12, 2020

#371 was technically a breaking change because the users cannot declare the same name property with hooks as we restrict property types.

For example, there are users declaring data property as just a data:

@Component
class MyComp extends Vue {
  data = 'my data'
}

Since v7.2.0, above code produces compile error as it conflicts data hook type. https://github.com/vuejs/vue-class-component/blob/master/src/lifecycle.ts#L5

Although IMO it should be avoided to use the same name with hooks for property name to avoid confusion, this had been working in the previous version. So we should keep that behavior.

To solve this problem, I disabled the type augmentation by default. When users want to use it, they can manually import it via vue-class-component/hooks.

// main.ts
import 'vue-class-component/hooks'
import Vue from 'vue'
import App from './App.vue'

new Vue({
  render: h => h(App)
}).$mount('#app')

@ktsn ktsn changed the title fix: avoid breakage not to auto augment hooks type fix: avoid breakage by not to auto augment hooks type Jan 12, 2020
@ktsn ktsn merged commit d54490b into master Jan 12, 2020
@ktsn ktsn deleted the fix-brakage branch January 12, 2020 07:13
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

Successfully merging this pull request may close these issues.

1 participant