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

Object API "this" is not defined on types with defineComponent #570

Closed
bbugh opened this issue Oct 18, 2020 · 5 comments
Closed

Object API "this" is not defined on types with defineComponent #570

bbugh opened this issue Oct 18, 2020 · 5 comments
Labels
bug Something isn't working typing

Comments

@bbugh
Copy link

bbugh commented Oct 18, 2020

We're incrementally adding the composition-api using defineComponent, and ran into a snag with one of our components that uses $route in the data function:

image

This code works fine with defineComponent, it's just the typing that doesn't.

Possibly related to #338?

@antfu
Copy link
Member

antfu commented Oct 20, 2020

Can you share a reproduction on CodeSandbox? It looks fine to me.

@antfu antfu added the needs reproduction We need a runnable reproduction from the OP label Oct 20, 2020
@bbugh
Copy link
Author

bbugh commented Oct 22, 2020

Sure, here's a reproduction CodeSandbox. The error appears in App.vue.

image

image

@antfu antfu added bug Something isn't working typing and removed needs reproduction We need a runnable reproduction from the OP labels Oct 22, 2020
antfu added a commit to antfu/composition-api that referenced this issue Oct 23, 2020
@meschg
Copy link

meschg commented Oct 31, 2020

Hello,
I come to this issue through #338 #406 but I am not sure which issue is the right one - sorry :/.
Code execution is working in Browser without any error just VS Code does not know what to make out of it...
20201031_112625_type-comp-error

"minimal" sample project:
https://github.com/meschg/vue-stack-cesium/blob/53755243c08f36ea1c3a93181ef8b643556ef81c/src/components/HelloCompositionAPIExternal.vue#L65

Thanks for all your effort!
kind regards

@pikax
Copy link
Member

pikax commented Nov 1, 2020

@meschg the reason is because of your computed: mapState is breaking the types. That's a known typescript issue with vue, nothing can be done aside of setting a type to it.

@meschg
Copy link

meschg commented Nov 1, 2020

@meschg the reason is because of your computed: mapState is breaking the types. That's a known typescript issue with vue, nothing can be done aside of setting a type to it.

@pikax Ah good to know - wasn't sure. But I think your answer will also help others with the same error :). Thank you

@antfu antfu closed this as completed in 9a5b438 Nov 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working typing
Projects
None yet
Development

No branches or pull requests

4 participants