Skip to content

Using generics is making required props optional when using fallthrough #13521

Closed
@rasmus0201

Description

@rasmus0201

Vue version

3.5.17

Link to minimal reproduction

https://play.vuejs.org/#eNp9U9Fu2zAM/BVOL9mAxMGQFRs8N8BadED30BWrsScBg2YzjlJb0iQ6TRHk30fJTdIWRR55JE/H83krvjmXrXsUuShC5bUjCEi9g1aZ5lwKClLMpdGds57gQgW8Nq4nWHjbwSibHpBIMvoqjTTFdCDiNS4IO9cqQq4AineTCdxY0hUCLRWBFAuNbS0F6ADGQmtNgx48/uu1xxqUqYEeHT5Jqy3GMYLKRlZtYDI5Epf+kTc7u9amYXqEUVwdgfPWjQeqJRoo7+DB+vsAKgBuHFbED+15jhfG3WgAbojlTbldTJ8dI8bsTWXNQjfZKljDBm4jgxRRm27R/3SkrWH/ckid2FNtax9+JIx8j+M9Xi2xun8DX4VNxKS49RjQr1GKQ4+Ub5C1xfbV3U3SeWh2tu5bnj7R/IXBtn3UOIxd9KZm2c/mktrr9OnZ0jJcbQhN2B8VhcbJXZqXggNweeL0o9xZ9intSbNjF18k6FQMoUGDXldclimUHEtD6BeK0/Q9xujScr2hopwPzxrVYQ6BPKvnaAKsVdszUqaiQ1I52L8rTgADLEca/qCBYAsplbCDc6hxoQ3ecoRCkUhTK3/54PAES9rN339grlO/gE7pypMUPiXRZalKR70O2Z81+mg5OzPLzrKPnyNG4fcBPcu+ZDOx+w9m10aN

Steps to reproduce

Create a component with a generic (<script setup lang="ts" generic="T">).

Use the component and provide a prop that is not in the props list (e.g. a fallthrough attribute)

Notice that required props in the component is no longer required and typescript allows the usage without the prop.

What is expected?

Required props should be required and typescript should be aware of missing prop.

What is actually happening?

The way generic="" is altering defineProps is making required props optional.

System Info

Any additional comments?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions