Skip to content

Remove irrelevant types from JSX namespace #2706

@remcohaszing

Description

@remcohaszing

The JSX namespace in TypeScript has a special meaning. There’s a specific set of types that can be defined in a JSX namespace to make JSX behave in a certain way. This is (partially) documented here.

The following properties have a special meaning:

  • Element
  • ElementClass
  • ElementAttributesProperty
  • ElementChildrenAttribute
  • IntrinsicAttributes
  • IntrinsicElements
  • LibraryManagedAttributes

However, in the Preact typings the following types are also defined on the JSX namespace:

  • SVGAttributes
  • PathAttributes
  • DOMAttributes
  • HTMLAttributes

Events and event handlers

  • TargetedEvent
  • TargetedAnimationEvent
  • TargetedClipboardEvent
  • TargetedCompositionEvent
  • TargetedDragEvent
  • TargetedFocusEvent
  • TargetedKeyboardEvent
  • TargetedMouseEvent
  • TargetedPointerEvent
  • TargetedTouchEvent
  • TargetedTransitionEvent
  • TargetedUIEvent
  • TargetedWheelEvent
  • EventHandler
  • AnimationEventHandler
  • ClipboardEventHandler
  • CompositionEventHandler
  • DragEventHandler
  • FocusEventHandler
  • GenericEventHandler
  • KeyboardEventHandler
  • MouseEventHandler
  • PointerEventHandler
  • TouchEventHandler
  • TransitionEventHandler
  • UIEventHandler
  • WheelEventHandler

The JSX namespace in Preact is called JSXInternal. This makes it unclear if these types are supposed to be consumed or not.

Since these types are useful, especially the event handlers, I propose to move all these types to the preact namespace instead. The JSXInternal namespace can import these types an expose type aliases using the @deprecated annotation. They can be removed in the next major release.

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