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

SFC compiler breaks TypeScript when using <script> with <script setup> #5094

eliottrobson opened this issue Dec 11, 2021 · 0 comments


Copy link

eliottrobson commented Dec 11, 2021



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.

	<h1>{{ value }}</h1>

<script lang="ts">
export default {
	inheritAttrs: false

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

const props = defineProps({
	test: {
		type: String,
		default: ''
const value = computed(() => props.test);

Valid TypeScript output:

Invalid TypeScript output:

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

@github-actions github-actions bot locked and limited conversation to collaborators Oct 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
None yet

No branches or pull requests

1 participant