ezolenko / rollup-plugin-typescript2

Rollup plugin for typescript with compiler errors.
MIT License
819 stars 71 forks source link

Vue 3 Script Setup syntax + style tag scoped = TS error #469

Closed gde-pass closed 5 months ago

gde-pass commented 5 months ago

Rollup Version

4.12.0

Operating System (or Browser)

Chrome

Node Version (if applicable)

18.13.0

Link To Reproduction

https://github.com/gde-pass/Vue3-Design-System-Template (there is a specific branch)

Expected Behaviour

Build without error when i have a vue 3 component using script setup syntax + style tag with scoped property

Actual Behaviour

When i try to build my design system with a component using script setup syntax and with a scoped style tag i get this error:

[!] (plugin rpt2) RollupError: src/components/testworld/TestWorld.vue?vue&type=script&setup=true&lang.ts:4:22 - error TS7006: Parameter 'n' implicitly has an 'any' type.

The error is gone when:

To be very clear, those 2 following components will NOT generate any error during build time:

<template>
    <h1>
      {{ age }}
    </h1>
</template>

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

export default defineComponent({
  props: {
    age: {
      type: Number as PropType<number>,
      required: true,
    },
  },
});
</script>

<style lang="scss" scoped>
@import "../../assets/scss/tailwind";
</style>
<template>
    <h1>
      {{ age }}
    </h1>
</template>

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

defineProps({
  age: {
    type: Number as PropType<number>,
    required: true,
  },
});
</script>

<style lang="scss">
@import "../../assets/scss/tailwind";
</style>

And this is a component generating the error above:

<template>
    <h1>
      {{ age }}
    </h1>
</template>

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

defineProps({
  age: {
    type: Number as PropType<number>,
    required: true,
  },
});
</script>

<style lang="scss" scoped>
@import "../../assets/scss/tailwind";
</style>
agilgur5 commented 5 months ago

Do not remove the issue template, it is there for a reason. You seem to have copy+pasted a different repo's issue template instead of filling out rpt2's. They are not the same.

Link To Reproduction

https://github.com/gde-pass/Vue3-Design-System-Template (there is a specific branch)

This is also not a minimal reproduction. The Rollup config is very complex. It's very difficult to debug something with so many moving pieces, many of which are not rpt2.

error TS7006: Parameter 'n' implicitly has an 'any' type.

This is a TS error, not an rpt2 specific error. Why do you assume this error is incorrect? rpt2's issue template, which you did not fill out, explicitly asks you to compare the output to tsc, as if they have the same output, that is not a bug.

Additionally, I see you posted this to Rollup's repository as well in https://github.com/rollup/rollup/issues/5416, despite there being no indication that this is a Rollup bug. I agree with the Rollup maintainer that this very much looks like an issue with the Vue typings or Vue SFC compiler and not rpt2 -- it seems like it's producing code with a type checking error. This would also not be the first such bug with Vue, see also #440, #325, #235, and others -- in nearly all cases it was a Vue issue.