vitejs / vite-plugin-vue2

Vite plugin for Vue 2.7
MIT License
551 stars 47 forks source link

Problem with using typescript decorator #89

Open hatedMe opened 1 year ago

hatedMe commented 1 year ago
import { Vue, Component, Prop } from "vue-property-decorator";
import Layout from "../Layout.vue";
@Component({
    components: {
        Layout,
    }
})
export default class extends Vue {
 // someing code 
}

Is there a feasible solution for the above code?

drikusroor commented 1 year ago

Hi @hatedMe I might have the same problem but I'm getting

Uncaught SyntaxError: Invalid or unexpected token (at SomePage.vue:39:1)

when I try to use vue-class-component. Is that the same error you are referring to?

chessydk-vertica commented 7 months ago

Hade the same problem and found out that I had enabled typescript decorators the wrong place, namely in tsconfig.app.json. It needs to go into your top level tsconfig.json - like this:

{
  "files": [],
  "compilerOptions": {
    "experimentalDecorators": true,
  },
  "references": [
    {
      "path": "./tsconfig.node.json"
    },
    {
      "path": "./tsconfig.app.json"
    }
  ]
}
Fonigle commented 7 months ago

Hade the same problem and found out that I had enabled typescript decorators the wrong place, namely in tsconfig.app.json. It needs to go into your top level tsconfig.json - like this:

{
  "files": [],
  "compilerOptions": {
    "experimentalDecorators": true,
  },
  "references": [
    {
      "path": "./tsconfig.node.json"
    },
    {
      "path": "./tsconfig.app.json"
    }
  ]
}

it works, you saved my day! thanks! @chessydk-vertica

chessydk-vertica commented 7 months ago

Glad to hear!

Med venlig hilsen

Carsten Hess Extern frontender E-mail: @.**@.> Direct: +4551300250


Fra: HuangYu @.> Sendt: 22. april 2024 10:45 Til: vitejs/vite-plugin-vue2 @.> Cc: Carsten Hess @.>; Comment @.> Emne: Re: [vitejs/vite-plugin-vue2] Problem with using typescript decorator (Issue #89)

Hade the same problem and found out that I had enabled typescript decorators the wrong place, namely in tsconfig.app.json. It needs to go into your top level tsconfig.json - like this:

{ "files": [], "compilerOptions": { "experimentalDecorators": true, }, "references": [ { "path": "./tsconfig.node.json" }, { "path": "./tsconfig.app.json" } ] }

it works, you saved my day! thanks!

— Reply to this email directly, view it on GitHubhttps://github.com/vitejs/vite-plugin-vue2/issues/89#issuecomment-2068832954, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BEJCGV3OERTJBEZTRJFAODDY6TEZLAVCNFSM6AAAAAAZ7X52SOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANRYHAZTEOJVGQ. You are receiving this because you commented.Message ID: @.***>