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

Disable volar type checking for template attributes #176

Closed
mseele opened this issue May 11, 2021 · 7 comments
Closed

Disable volar type checking for template attributes #176

mseele opened this issue May 11, 2021 · 7 comments
Labels
question Further information is requested

Comments

@mseele
Copy link

mseele commented May 11, 2021

I got a (wrong) typescript error for placeholder attribute.

<Textbox
            v-if="isTextbox"
            :id="data.columnKey"
            :key="index"
            v-model="record.value.proposal"
            :placeholder="record.value.released"
            :name="data.columnKey"
            :label="label(record)"
            class="col-span-full"
          />

It should be possible to tell typescript via @ts-ignore or @ts-expect-error to skip these errors

@johnsoncodehk
Copy link
Member

johnsoncodehk commented May 11, 2021

You can use @ts-ignore in expression and interpolation in template, but :placeholder="record.value.released" across over html and expression content, we can't support something like @ts-ignore for that without a new syntax, so you can only define a helper function to resolve.

<template>
...
:placeholder="asAny(record.value.released)"
...
</template>

<script lang="ts">
...
const asAny = (foo: any) => foo as any;
...
</script>

When vue support typescript in template(vuejs/core#1359), you can do this :placeholder="record.value.released as any".

@johnsoncodehk johnsoncodehk added the question Further information is requested label May 11, 2021
@neal2018
Copy link

neal2018 commented May 17, 2021

Hey, I am using JavaScript so I am not able to use an asAny helper function to convert type.
Is there any other workaround? Any help is appreciated.

@johnsoncodehk
Copy link
Member

@neal2018 Just remove types from function in js: const asAny = (foo) => foo;

@filiperaupp-egsys
Copy link

There is a way to disable type check on template properties? I'm using the last version of Volar
image

@olivierlauzon85
Copy link

@filiperaupp-egsys did you figure out a way? I am migrating a project from Vue2 to Vue3, and as much as I like having type checks in template, I would like to disable them for now.

@filiperaupp-egsys
Copy link

@olivierlauzon85 unfortunately i didn't find a right way to resolve this. But, in my case, i could use a workaround adding type to the prop on the template, like this:

<q-input>
  ...,
  :type="(type as any)"
/>

@johnsoncodehk
Copy link
Member

@filiperaupp-egsys Currently there is no way, unless we introduce additional syntax for this. If you think this feature is still needed, please open a feature request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

5 participants