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

TypeScript with noImplicitAny: true and SFC without script tag #2074

Open
Ixonal opened this issue May 6, 2024 · 0 comments
Open

TypeScript with noImplicitAny: true and SFC without script tag #2074

Ixonal opened this issue May 6, 2024 · 0 comments

Comments

@Ixonal
Copy link

Ixonal commented May 6, 2024

Soooo this is a pretty obscure issue I found. I have a project that's using TypeScript, and I want to turn on the noImplicitAny option. When I do so, compilation fails on any single file components that don't have a script setup block with lang set to "ts" and some form of content (even if just comments). This seems to be because the parameters to the generated render function lack types. I'm guessing the lang part of things is what notifies vue to generate the types, and empty tags are pruned before the lang attribute is seen. Is there some way to notify the plugin that all loaded script tags will be typescript? Or do I need to add the redundant script tag to every component that doesn't have behavior?

Here's an example of what I'm talking about

<script setup lang="ts">
  //this is required if we're to have noImplicitAny: true
  //both the lang being set to ts and these comments are needed
  //for the emitted code to have types associated with parameters
</script>

<template>
  <h1 class="text-primary fw-bold text-center border-bottom border-primary pt-3 pb-3">
    <slot></slot>
  </h1>
  <div class="pb-3"></div>
</template>
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

1 participant