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

Add support for analyzing vue-class-component and vue-property-decorator #1323

Merged
merged 16 commits into from
Aug 14, 2020

Conversation

yoyo930021
Copy link
Member

@yoyo930021 yoyo930021 commented Jun 7, 2019

Fixed #1105.
Fixed #864.

I want to support vue-property-decorator.
Reason:

  1. Vue 3.0 isn't built-in class component. rfc
  2. vue-property-decorator is built-in vue-cli 3 typescript plugin.
  3. vue-typescript project latest update was three years ago.

I'm not add test.
I will try to add.

@yoyo930021 yoyo930021 force-pushed the support-class-component branch from d954ea9 to f427c88 Compare June 8, 2019 15:08
@yoyo930021 yoyo930021 changed the title Add support analyzing vue-class-component and vue-property-decorator Add support analyzing vue-class-component and vue-property-decorator Jun 10, 2019
@yoyo930021
Copy link
Member Author

yoyo930021 commented Jun 22, 2019

I will disappear for two weeks.
If this PR can help this project, you can edit it directly.

@yoyo930021 yoyo930021 force-pushed the support-class-component branch from 5bf17c4 to 74c76da Compare June 23, 2019 17:50
@yoyo930021 yoyo930021 force-pushed the support-class-component branch 2 times, most recently from cf7cf5a to a592bbd Compare July 7, 2019 08:47
@yoyo930021
Copy link
Member Author

I fixed the test error.

@antsteyer
Copy link

Please merge it

@qwqcode
Copy link

qwqcode commented Jul 27, 2019

Please merge it!!

@yoyo930021 yoyo930021 force-pushed the support-class-component branch from a592bbd to 283d831 Compare July 30, 2019 12:39
@octref octref added this to the On Deck milestone Aug 7, 2019
@Angeart
Copy link

Angeart commented Aug 8, 2019

Please merge it!!!!

@lbland94
Copy link

lbland94 commented Aug 22, 2019

Testing locally, this appears to work perfectly for properties defined on the class. It does seem to exclude both @Injected properties or properties like $route defined by a vue plugin. Are those out of scope for this feature?

@yoyo930021
Copy link
Member Author

yoyo930021 commented Aug 23, 2019

@lbland94
The component data only has props, data, computed and methods by design in Vetur.
I don't know where the inject data is placed. @octref

The Vue defined property isn't supported in the template for now.

@yoyo930021 yoyo930021 force-pushed the support-class-component branch from 8bc884f to 7e18717 Compare August 23, 2019 02:44
@antsteyer
Copy link

@yoyo930021 is it possible for you to publish your repo as VS Code extension ? So boring to not have this feature merged yet

@yoyo930021
Copy link
Member Author

@antsteyer
I think you can clone this PR by using it.

  1. compile
git clone https://github.com/yoyo930021/vetur.git
git checkout support-class-component
yarn
cd server && yarn && cd ..
yarn compile
  1. set the vetur config to using it
    vetur.dev.vlsPath set to <projectUrl>/server in vscode config.

PS. https://github.com/vuejs/vetur/blob/master/.github/CONTRIBUTING.md

@yoyo930021 yoyo930021 force-pushed the support-class-component branch 2 times, most recently from 200d1a6 to 6b89257 Compare October 28, 2019 10:06
@SaphuA
Copy link

SaphuA commented Nov 9, 2019

I just tried out this branch and it's working quite well on first glance! Great work!

I'm using Vuex in combination with vuex-class-components and it seems this version of Vetur is unable to intellisence beyond "this.store", even though it displays the type correctly. Is this as expected or should this work as well?

@theoribeiro
Copy link

Is there a reason why this still wasn't merged or is it just due to maintainers' capacity?

@annnoo
Copy link

annnoo commented Dec 3, 2019

@SaphuA Got the same issue, but I guess this should get fixed :( I could maybe take a look, but I've never done any vscode extension development and I don't think I am able to fix this

@yoyo930021
Copy link
Member Author

@SaphuA @annnoo I think #1446 can fix it.

@ZhengXiaowei
Copy link

wasn't merged ? how to solve this problem? complie this branch?

@yoyo930021
Copy link
Member Author

#1323 (comment)

@ZhengXiaowei
Copy link

#1323 (comment)

thx, it's work great

@yoyo930021
Copy link
Member Author

yoyo930021 commented Jul 28, 2020

@octref Oh I know.
It's wrong tests about kind when we replace typescript info to vueFileInfo.

I will fix it.

@yoyo930021 yoyo930021 marked this pull request as draft July 30, 2020 06:07
@yoyo930021 yoyo930021 force-pushed the support-class-component branch from 97e4bff to 74374b1 Compare August 1, 2020 06:54
@yoyo930021 yoyo930021 marked this pull request as ready for review August 1, 2020 07:00
@yoyo930021 yoyo930021 requested a review from octref August 3, 2020 03:52
@tjhiggins
Copy link

@yoyo930021
Copy link
Member Author

@yoyo930021 will this also work for https://github.com/nuxt-community/nuxt-property-decorator?

I don't know this library existed.
I don't think there's anything wrong with a quick scan.

@octref octref changed the title Add support analyzing vue-class-component and vue-property-decorator Add support for analyzing vue-class-component and vue-property-decorator Aug 14, 2020
Copy link
Member

@octref octref left a comment

Choose a reason for hiding this comment

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

Great work 👍 Sorry it took me this long.

@aziztitu
Copy link

aziztitu commented Mar 20, 2021

When using the Emit decorator, I get this weird issue when providing an inline event callback in the template.

Here's how the event is declared using Emit decorator:

@Component()
export default class LeaveApplicationForm extends Vue {
  @Emit()
  private onSubmit() {
    this.reset();
    return;
  }
}

And this is how I'm providing the event callback in the template:

<LeaveApplicationForm
  @on-submit="showLeaveApplicationDialog = false"    // If I pass a function here, the error disappears
>
</LeaveApplicationForm>

And this is the error I get:

(property) 'on-submit'?: (($event: any) => (arg: undefined) => any) | undefined

Type 'typeof "on-submit"' is not assignable to type '($event: any) => (arg: undefined) => any'.
  Type '"on-submit"' is not assignable to type '(arg: undefined) => any'.
    Type '"on-submit"' provides no match for the signature '(arg: undefined): any'.Vetur(2322)

Note: This error does not show up if I pass a function as the callback instead.

I think the reason is that when using the Emit decorator, the type of the event is being recognized as (($event: any) => (arg: undefined) => any) | undefined.
But it should be something like ($event: any) => void or ($event: any) => CallableFunction | undefined

Not quite sure if the issue is with Vetur or the vue-property-decorator library.

Does anyone else have this same issue?

How does Vetur find the type of the events?

@yoyo930021
Copy link
Member Author

yoyo930021 commented Apr 13, 2021

When using the Emit decorator, I get this weird issue when providing an inline event callback in the template.

Here's how the event is declared using Emit decorator:

@Component()
export default class LeaveApplicationForm extends Vue {
  @Emit()
  private onSubmit() {
    this.reset();
    return;
  }
}

And this is how I'm providing the event callback in the template:

<LeaveApplicationForm
  @on-submit="showLeaveApplicationDialog = false"    // If I pass a function here, the error disappears
>
</LeaveApplicationForm>

And this is the error I get:

(property) 'on-submit'?: (($event: any) => (arg: undefined) => any) | undefined

Type 'typeof "on-submit"' is not assignable to type '($event: any) => (arg: undefined) => any'.
  Type '"on-submit"' is not assignable to type '(arg: undefined) => any'.
    Type '"on-submit"' provides no match for the signature '(arg: undefined): any'.Vetur(2322)

Note: This error does not show up if I pass a function as the callback instead.

I think the reason is that when using the Emit decorator, the type of the event is being recognized as (($event: any) => (arg: undefined) => any) | undefined.
But it should be something like ($event: any) => void or ($event: any) => CallableFunction | undefined

Not quite sure if the issue is with Vetur or the vue-property-decorator library.

Does anyone else have this same issue?

How does Vetur find the type of the events?

Please open a new issue.

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