Giter VIP home page Giter VIP logo

Comments (10)

johnsoncodehk avatar johnsoncodehk commented on May 22, 2024 1

this error is not from volar, I think eslint may not support new <script setup>, sorry I don't have use eslint so I can't say how to fix...

from language-tools.

johnsoncodehk avatar johnsoncodehk commented on May 22, 2024

Hi @soulsam480, what is your vue version? if you using [email protected] or new, <script setup> has changed, it don't use export anymore.

I you are using [email protected] or old, please change vscode setting "volar.scriptSetup.supportRfc": "#182" and reload vscode, it would support the old version <script setup>.

But in the future, old <script setup> will remove, please see: #27

from language-tools.

soulsam480 avatar soulsam480 commented on May 22, 2024

what is your vue version?

Hii, I'm using [email protected]. Ok sure then, I'll check

from language-tools.

soulsam480 avatar soulsam480 commented on May 22, 2024

what is your vue version?

Hii, I'm using [email protected]. Ok sure then, I'll check

Just removed the export and now it shows 'userList' is assigned a value but never used.eslint@typescript-eslint/no-unused-vars

from language-tools.

soulsam480 avatar soulsam480 commented on May 22, 2024

Ohh sure. Also I just noticed that without the export, the data is not being exposed to template. I mean not being accessible from the remplate during render.

I'll just check in Vue 3 issues.

from language-tools.

johnsoncodehk avatar johnsoncodehk commented on May 22, 2024

you don't need export in new <script setup>, check here: https://github.com/vuejs/rfcs/blob/script-setup-2/active-rfcs/0000-script-setup.md#top-level-bindings-are-exposed-to-template

from language-tools.

schw4rzlicht avatar schw4rzlicht commented on May 22, 2024

I think this is an issue though. I am using vue-tsc for type checking on CI and something like this also fails:

<script lang="ts" setup>
export interface ComponentProps {
  myProps: string;
}

defineProps<ComponentProps>();
</script>

...but I actually need the export so that I can use the interface somewhere else.

from language-tools.

johnsoncodehk avatar johnsoncodehk commented on May 22, 2024

@schw4rzlicht try:

<script lang="ts">
export interface ComponentProps {
  myProps: string;
}
</script>

<script lang="ts" setup>
defineProps<ComponentProps>();
</script>

from language-tools.

schw4rzlicht avatar schw4rzlicht commented on May 22, 2024

This helps in some cases. But I just found another one not working:

<script lang="ts">
import { PlayerError } from "./errors/PlayerError";

export interface ErrorViewProps {
    error: PlayerError;
}

export interface ErrorViewEmits {
    (e: "retry"): void;
}
</script>

<script lang="ts" setup>
const props = defineProps<ErrorViewProps>();

defineEmits<ErrorViewEmits>();
</script>

This one fails with:

[plugin:vite:vue] Transform failed with 1 error:
/Users/**/src/ErrorView.vue:20:67: ERROR: Expected ")" but found "("

/Users/**/src/ErrorView.vue:20:67
Expected ")" but found "("
18 |    },
19 |    emits: ["retry"],
20 |    setup(__props: any, { expose }: { emit: ( computed<string | null>(()), expose: any, slots: any, attrs: any }) {
   |                                                                     ^
21 |    expose();
22 |

In this case, I don't even need export, but when doing vue-tsc --emitDeclarationOnly (and thus having declarations: true in tsconfig.json, vue-tsc fails with:

src/ErrorView.vue:34:25 - error TS4082: Default export of the module has or is using private name 'ErrorViewProps'.

34 <script lang="ts" setup>
35 import { computed, onMounted, onUnmounted, ref, watch } from "vue";
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
... 
118 });
    ~~~
119 </script>   

But I need declarations as I am building a library :(

from language-tools.

johnsoncodehk avatar johnsoncodehk commented on May 22, 2024

@schw4rzlicht could you provide minimal reproduction?

from language-tools.

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.