Code Monkey home page Code Monkey logo

Comments (8)

3ximus avatar 3ximus commented on July 19, 2024 1

Thank you for the quick reply, both solutions worked for me. Do you know how "shameful" this experimentalShamefullySupportOptionsApi is ?
Because I would rather use the Options API as it is in the documentation without the defineComponent function.

Cheers

from coc-volar.

yaegassy avatar yaegassy commented on July 19, 2024 1

The latest version was released yesterday via upstream. coc-volar has also been updated. Try run :CocUpdate and update your extensions

from coc-volar.

yaegassy avatar yaegassy commented on July 19, 2024

Try using defineComponent.

<script lang="ts">
import { defineComponent } from "vue";

export default defineComponent({
  data() {
    // ...snip
  },
  methods: {
    // ...snip
  },
});
</script>

Or use the <script setup lang="ts">.

from coc-volar.

yaegassy avatar yaegassy commented on July 19, 2024

@3ximus If you want to use export default { ... } as it is, try adding a settings. Adding vueCompilerOptions.experimentShamefullySupportOptionsApi settings to tsconfig.json may solve the problem.

For projects created in create-vue (npm init vue), try adding settings to tsconfig.app.json.


tsconfig.app.json:

{
  "extends": "@vue/tsconfig/tsconfig.web.json",
  "include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
  "exclude": ["src/**/__tests__/*"],
  "compilerOptions": {
    "composite": true,
    "baseUrl": ".",
    "paths": {
      "@/*": ["./src/*"]
    }
  },
  // ---- here ----
  "vueCompilerOptions": {
    "experimentalShamefullySupportOptionsApi": true
  }
}

from coc-volar.

yaegassy avatar yaegassy commented on July 19, 2024

This is not a configuration item added by coc-volar on its own, but by upstream. If you are concerned about the name of the configuration, please submit an issue report upstream.

export default {...} is of course explained in the official vue documentation and is certainly nothing to be shamefull of. Of course, the same applies when using javascript instead of typescript.

In the current volar, it is recommended to use script setup or defineComponent in typescript because it is less trouble.

from coc-volar.

3ximus avatar 3ximus commented on July 19, 2024

I see, ok. Thank you for the reply and help.
Cheers πŸ‘

from coc-volar.

yaegassy avatar yaegassy commented on July 19, 2024

@3ximus It looks like experimentalShamefullySupportOptionsApi option will be enabled by default in the next upstream update. The diagnostic message appears as a warning, not a error. vuejs/language-tools@e361bdd72aefe4818c5a40e87d11b61672fdf6adA

from coc-volar.

3ximus avatar 3ximus commented on July 19, 2024

Oh that's great πŸ‘
Thank you!

from coc-volar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.