Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Open
@windsonR

Description

@windsonR

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}) />)

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