Skip to content

Typescript declaration for mathfieldelement needs declare module, not declare global, in React 19 #2937

@dkilfoyle

Description

@dkilfoyle

In documentation https://mathlive.io/mathfield/guides/react/#using-a-mathfield-with-react-and-typescript

For React 19 need to replace declare global {...} with

declare module "react/jsx-runtime" {
  namespace JSX {
    interface IntrinsicElements {
      "math-field": DetailedHTMLProps<HTMLAttributes<MathfieldElement>, MathfieldElement>;
    }
  }
}

export {};

See https://stackoverflow.com/questions/79580197/typescript-cant-handle-new-element-in-jsx-intrinsicelements-in-new-vite-project

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions