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

Support for script syntactical sugar "setup" #14

Closed
onx2 opened this issue Oct 28, 2020 · 3 comments
Closed

Support for script syntactical sugar "setup" #14

onx2 opened this issue Oct 28, 2020 · 3 comments
Labels
bug Something isn't working

Comments

@onx2
Copy link

onx2 commented Oct 28, 2020

I attempted to use the setup="props" shorthand with TS but it doesn't seem to work - is there a plan to support this while it is experimental?

Heres an example of what i'm attempting:

HelloWorld.vue

<script lang="ts" setup="props">
import { ref } from "vue"

declare const props: {
  msg: string
}

export const count = ref(0);
</script>

<template>
 <div>
    {{ count }}
    <button @click="count++">Add</button>
  </div>
</template>

App.vue
Import the HelloWorld component; the props aren't registered when hovering over the component in the template, prop completion and type checking aren't working, and missing a prop doesn't error highlight the component.

  • Create vite app
  • Add typescript pkg and vue shim
  • Add volar shims
  • Update files to use TS (index.html and .vue files' script tag)

BTW this is looking great so far, really good work! Thanks for your time 😄

@johnsoncodehk
Copy link
Member

johnsoncodehk commented Oct 28, 2020

Thank you for your report :) I will take a look at declare const props.
Currently you can do this:

export default defineComponent({
	props: {
		msg: { type: String, required: true }
	}
})

@johnsoncodehk
Copy link
Member

fixed in 0.14.5

@onx2
Copy link
Author

onx2 commented Oct 28, 2020

Wow, that was quick. Thanks!

@johnsoncodehk johnsoncodehk added the bug Something isn't working label Nov 28, 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
Projects
None yet
Development

No branches or pull requests

2 participants