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

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

merged 2 commits into from Jan 12, 2020

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
5 checks passed
5 checks passed
ci/circleci: build Your tests passed on CircleCI!
Details
ci/circleci: example-build Your tests passed on CircleCI!
Details
ci/circleci: install Your tests passed on CircleCI!
Details
ci/circleci: lint Your tests passed on CircleCI!
Details
ci/circleci: test Your tests passed on CircleCI!
Details
@ktsn ktsn deleted the fix-brakage branch Jan 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

1 participant
You can’t perform that action at this time.