Vue composition API: missing `useRef<T>` generic types
See original GitHub issuemitosis component:
import { useState } from "@builder.io/mitosis";
interface Props {
name: string
age: number
}
export default function MyComponent(props: Props) {
const [name, setName] = useState("Steve");
return (
<div>
{ props.name }
<input
css={{
color: "red",
}}
value={name}
onChange={(event) => setName(event.target.value)}
/>
Hello! I can run in React, Vue, Solid, or Liquid!
</div>
);
}
the vue-compsition result:
<template>
<div>
{{ age }}
{{ name }}
<input class="input" :value="name" @input="name = $event.target.value" />
Hello
{{ name }}! I can run in React, Vue, Solid, or Liquid!
</div>
</template>
<script setup>
import { ref } from "vue";
const props = defineProps(["age", "name"]);
const name = ref("Steve");
</script>
<style scoped>
.input {
color: red;
}
</style>
Hope to support vue3-composition-types feature. Such as defineProps<T>
, ref<T>
and so on. I am also interesting to implement the feature.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
How to solve Vuejs composition API's Ref() type Error?
I am using vue composition API and using a ref for an array of objects which each object has a value property, it...
Read more >TypeScript, template refs and computed property #624 - GitHub
The following example doesn't explain how to correctly use ref inside computed function. Inside of setup() : const element = ref(null); // type...
Read more >Composition API FAQ - Vue.js
What is Composition API? #. Composition API is a set of APIs that allows us to author Vue components using imported functions instead...
Read more >Generically Typed Vue Components with Composition API
Generic props Let's start with a simple goal. We need to define a generic component that accepts a value prop that can be...
Read more >Vue 3 with TypeScript Tutorial #3 - Composition API ...
In this Vue 3 & TypeScript tutorial we'll dive into using the Composition API with TypeScript. You'll learn how to type reactive state ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ok,i will try it
I’ll try it later.