vue icon indicating copy to clipboard operation
vue copied to clipboard

When using spread syntax in tsx file, will cause a type error: TS2559

Open windsonR opened this issue 1 year ago • 0 comments

Version

2.7.8

Reproduction link

codesandbox.io

Steps to reproduce

  1. create two file A.tsx,B.tsx
  2. A.tsx content:
/* eslint-disable */
import { defineComponent } from "vue";
import B from "./B";

export default defineComponent({
  props: {
    aProps: String
  },
  render() {
    const props = {
      props: {
        bProps: "bb"
      }
    };

    return <B {...props} />;
  }
});
  1. B.tsx,content
import { defineComponent } from "vue";

export default defineComponent({
  props: {
    bProps: String
  },
  render() {
    return <h1>bb</h1>;
  }
});
  1. in A.tsx, render function's return <B will report an error

What is expected?

when use spread props, there is no type error

What is actually happening?

defineComponent's return type may not support using spread props (like this: <B {...bProps}) />)

windsonR avatar Jul 26 '22 02:07 windsonR