Skip to content

feat(language-core): check required fallthrough attributes#6049

Merged
KazariEX merged 5 commits into
vuejs:masterfrom
KazariEX:feat/check-required-fallthrough-attributes
May 17, 2026
Merged

feat(language-core): check required fallthrough attributes#6049
KazariEX merged 5 commits into
vuejs:masterfrom
KazariEX:feat/check-required-fallthrough-attributes

Conversation

@KazariEX

@KazariEX KazariEX commented May 16, 2026

Copy link
Copy Markdown
Member

resolve #5882

Consider the following structure:

<!-- basic.vue -->
<script lang="ts" setup>
  defineProps<{
    foo: string;
    bar: string;
  }>();
</script>
<!-- comp.vue -->
<script lang="ts" setup>
  import Basic from "./basic.vue";
</script>

<template>
  <Basic />
</template>

When the fallthroughAttributes option is enabled on Comp, Comp inherits all props from Basic, allowing us to get prop completions for Basic when using Comp.

By default, however, the props inherited from Basic are all optional. This means we cannot enforce passing those required props when using Comp. At the same time, even if the required props from Basic are passed to Comp, Basic will still report missing prop errors.

After enabling the new checkRequiredFallthroughAttributes option on Comp, Comp will inherit Basic's props exactly as they are, and the missing prop errors on Basic inside Comp will disappear. This is because doing so is equivalent to promising that these required props should be passed when using Comp. Additionally, if some of the props required by Basic have already been passed directly to Basic, those props will be excluded from the inherited props.

@serkodev serkodev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In child.vue, if some props such as bar are already passed directly to the inner component, should bar still be required again when using the child component from main.vue? I would expect props already supplied by the wrapper to be excluded from the required fallthrough attrs.

<!-- child.vue -->
<!-- @checkRequiredFallthroughAttributes true -->

<script setup lang="ts">
import basic from './basic.vue';
</script>

<template>
  <basic bar="fixed" />
</template>
<!-- main.vue -->
<template>
  <!-- should not require bar prop here? -->
  <child />
</template>

Comment thread packages/language-core/lib/codegen/template/element.ts
@KazariEX KazariEX merged commit ee5e76a into vuejs:master May 17, 2026
4 checks passed
@KazariEX KazariEX deleted the feat/check-required-fallthrough-attributes branch May 17, 2026 17:39
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

Successfully merging this pull request may close these issues.

fallthroughAttributes improvements: requiredness and hiding

2 participants