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

types(router): added router array type for Array RouteConfig #4805

Merged
merged 3 commits into from Feb 28, 2020

Conversation

manuelojeda
Copy link
Contributor

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Docs
  • Underlying tools
  • Other, please describe:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

Other information:
This PR adds the type annotation to the const routes in router/index.ts when vue-router and TypeScript are selected in the CLI.
❌If you use the @vue/composition-api with both, router and TS selected, and error will pop up in the console as a shown in this image: https://i.imgur.com/NXugrHy.png

✅ After you add the annotation as stated in this PR there is no error shown in the console:
https://i.imgur.com/rq0S34U.png

Note: ❌ If you add the annotation type like const routes:<Array<RouteConfig>> an error will occur and won't accept the error: https://i.imgur.com/5gytWju.png

@sodatea
Copy link
Member

sodatea commented Nov 7, 2019

Sorry but I can't reproduce the error locally.
Do you have an reproduction repo? Did you use @vue/composition-api? If so, it should be a bug in that repo.

@manuelojeda
Copy link
Contributor Author

Of course, here is a basic repo builded with the CLI with TypeScript and Vue Router, and only added the @vue/composition-api.
I found out that the erorr occurs when you use the Composition API in a view, in this example just added the API at views/Home.vue

Here is the repo:
https://github.com/manuelojeda/vue-ts-router-composition-api

@masonk
Copy link

masonk commented Nov 11, 2019

vuejs/composition-api#185 is probably a dupe of this

Copy link
Member

@sodatea sodatea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that @vue/composition-api v0.4 has fixed this bug, we can go with the const routes: Array<RouteConfig> syntax.

@sodatea
Copy link
Member

sodatea commented Feb 28, 2020

Thanks!

@sodatea sodatea merged commit 84abd11 into vuejs:dev Feb 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants