Skip to content

Support multiple properties for JSX.ElementAttributesPropertyΒ #62193

@zhiyuanzmj

Description

@zhiyuanzmj

πŸ” Search Terms

"multiple properties", "JSX", "ElementAttributesProperty"

βœ… Viability Checklist

⭐ Suggestion

After Vue 3.6, introduce a new Vapor component (Non Virtual DOM) created by defineVaporComponent, it has a props property for JSX.ElementAttributesProperty to detect props.

const VaporComp = defineVaporComponent(() => {
  props: { foo: Number },
  setup: () => {
    return <div />
  }
})

const instance = new VaporComp({ foo: 1 })
instance.props
//       ^^^^^

And Vue also provide a interop mode, so that Vapor Component and Virtual DOM Component can be used together.

But the Virtual DOM Component created by defineComponent has a $props property for JSX.ElementAttributesProperty to detect props.

const VirtualComp = defineComponent({
  props: { foo: Number },
  setup: () => {
    return () => <div />
  }
})
const instance = new VirtualComp({ foo: 1 })
instance.$props
//       ^^^^^^

πŸ“ƒ Motivating Example

Support Vapor Component and Virtual DOM co-usage for Vue.
Or React Class Component and Vue Component co-usage.

πŸ’» Use Cases

  1. What do you want to use this for?
  • Supports define multiple properties for JSX.ElementAttributesProperty, so that Vapor Component (props) and Virtual DOM Component ($props) can used together.

    declare global {
      namespace JSX {
        interface ElementAttributesProperty { 
          $props;
          props;
        }
      }
    }
  1. What shortcomings exist with current approaches?
  • JSX.ElementAttributesProperty now only support define one property, if defined two perpoties will be expose a error.
  1. What workarounds are you using in the meantime?
  • None

This is implementation details: zhiyuanzmj@fcfbd3e

Metadata

Metadata

Assignees

No one assigned

    Labels

    Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureDomain: JSX/TSXRelates to the JSX parser and emitterNeeds ProposalThis issue needs a plan that clarifies the finer details of how it could be implemented.SuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions