Skip to content

Fixed type safety in props for Ref values.#469

Open
milospp wants to merge 1 commit intovue-final:masterfrom
milospp:feature/props-types
Open

Fixed type safety in props for Ref values.#469
milospp wants to merge 1 commit intovue-final:masterfrom
milospp:feature/props-types

Conversation

@milospp
Copy link
Copy Markdown

@milospp milospp commented Jun 4, 2025

Issue: #468

Resolves this problem

const reactiveLoading = ref(false)
const { open: openModal, close: closeModal } = useModal({
    component: LoadingComponent,
    attrs: {
        loading: reactiveLoading,
    },
})

Warning

Type 'Ref<boolean, boolean>' is not assignable to type 'boolean'.ts-plugin(2322)
(property) loading: globalThis.Ref<boolean, boolean>
Image

What is Expected?

It should accept both T and Ref<T>

@scott-the-brewer
Copy link
Copy Markdown

Unfortunately there is know way to reliably know if the props for a component support Ref<T>

Consider the below:

const { title } = defineProps<{ title: string }>()

This won't be reactive, unless toRef it called on title.

Overall, I'm still in favour of this PR - it provides a better developer experience.

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.

2 participants