question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Vue composition API: missing `useRef<T>` generic types

See original GitHub issue

mitosis 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:closed
  • Created a year ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
findlay-best-wishescommented, Sep 23, 2022

Ok,i will try it

0reactions
decadef20commented, Nov 7, 2022

I’ll try it later.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found