SFC compiler breaks TypeScript when using `<script>` with `<script setup>`
Version
3.2.24
Reproduction link
Steps to reproduce
When using <script>
with <script setup>
the generated TypeScript code is different enough to break the TypeScript compiler. When only using setup
the output can be correctly type checked. However, when using both, the output changes the output such that inferred types can no longer be inferred.
<template>
<h1>{{ value }}</h1>
</template>
<script lang="ts">
export default {
inheritAttrs: false
};
</script>
<script setup lang="ts">
import { computed } from 'vue';
const props = defineProps({
test: {
type: String,
default: ''
}
});
const value = computed(() => props.test);
</script>
What is expected?
The output should be valid TypeScript for both types
What is actually happening?
TS7006: Parameter '__props' implicitly has an 'any' type.
// ...
function setup(__props) {
const props = __props
// ...
It looks like the types are inferred, and when the extra __default__
object is created the setup
function is moved so it is defined outside the inferred usage scenario.
As far as I can tell, this started breaking from version 3.2.4
based on sfc.vuejs.org