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

error: Expected "class" but found "const" in Vite2 #503

Closed
lgl017 opened this issue Jan 7, 2021 · 5 comments
Closed

error: Expected "class" but found "const" in Vite2 #503

lgl017 opened this issue Jan 7, 2021 · 5 comments

Comments

@lgl017
Copy link

lgl017 commented Jan 7, 2021

I tried switch vite version to 1.0rc, it's fine, but error on 2.0
And if no "@options", it's fine too, but how can i include components

image
package.json

"dependencies": {
    "vue": "3.0.5"
  },
  "devDependencies": {
    "@vitejs/plugin-vue": "^1.0.4",
    "@vue/compiler-sfc": "^3.0.5",
    "@vuedx/typecheck": "^0.4.1",
    "@vuedx/typescript-plugin-vue": "^0.4.1",
    "sass": "^1.32.2",
    "typescript": "^4.1.3",
    "vite": "^2.0.0-beta.10",
    "vue-class-component": "^8.0.0-rc.1"
  }

App.vue

<script lang="ts">
// import { defineComponent } from 'vue'  
import HelloWorld from './components/HelloWorld.vue';  

import { Vue, Options } from 'vue-class-component';  

@Options({  
	components: {  
		HelloWorld,  
	},
})  
export default class App extends Vue {

}
</script>
@pruidong
Copy link

I also encountered this problem.

@MichaelSp
Copy link

I don't understand what you've shared. The App.vue doesn't match the content from your screenshot. Is that intentional? Than I don't get it.

@lgl017
Copy link
Author

lgl017 commented Jan 12, 2021

shared code is only script part in App.vue, others is same as new vite project(yarn create @vitejs/app viteProject --template vue-ts)

1.yarn create
2.yarn add...
3.modify app.vue to class style(shared code)
4.run dev then error

@lgl017
Copy link
Author

lgl017 commented Jan 12, 2021

I found same issue in vite here:
vitejs/vite#1476

@ktsn
Copy link
Member

ktsn commented Jan 12, 2021

This is more like Vite transpile issue.

@ktsn ktsn closed this as completed Jan 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants