microsoft / microsoft/TypeScript
Support multiple properties for JSX.ElementAttributesProperty
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Go
- Estrellas
- 111k
- Forks
- 14.3k
- Merge medio
- 2 d 4 h
- PR fusionados (30 d)
- 132
Descripción
🔍 Search Terms
"multiple properties", "JSX", "ElementAttributesProperty"
✅ Viability Checklist
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- This isn't a request to add a new utility type: https://github.com/microsoft/TypeScript/wiki/No-New-Utility-Types
- This feature would agree with the rest of our Design Goals: https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals
⭐ 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
- What do you want to use this for?
-
Supports define multiple properties for JSX.ElementAttributesProperty, so that
Vapor Component(props) andVirtual DOM Component($props) can used together.declare global { namespace JSX { interface ElementAttributesProperty { $props; props; } } }
- What shortcomings exist with current approaches?
- JSX.ElementAttributesProperty now only support define one property, if defined two perpoties will be expose a error.
- What workarounds are you using in the meantime?
- None
This is implementation details: https://github.com/zhiyuanzmj/TypeScript/commit/fcfbd3e1ea3c777b81ce6efbfb17808baafe29d5
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza con el comportamiento de JSX.ElementAttributesProperty de TypeScript y el commit de implementación enlazado; después, rastrea cómo se comprueba la búsqueda actual de una sola propiedad. Define cómo deben aceptarse tanto props como $props, preservando el comportamiento existente de JSX, y verifica que los ejemplos de componentes Vapor y Virtual DOM propuestos pasen la comprobación de tipos sin el error actual.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- typescript
- Área
- compilers
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 25/100