microsoft / microsoft/TypeScript

Support multiple properties for JSX.ElementAttributesProperty

Open
#62,193 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Awaiting More Feedback Domain: JSX/TSX Needs Proposal Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

🔍 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: https://github.com/zhiyuanzmj/TypeScript/commit/fcfbd3e1ea3c777b81ce6efbfb17808baafe29d5

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with TypeScript's JSX.ElementAttributesProperty behavior and the linked implementation commit, then trace how the current single-property lookup is checked. Define how both props and $props should be accepted while preserving existing JSX behavior, and verify that the proposed Vapor and Virtual DOM component examples type-check without the current error.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.