Skip to content

How can you type check React props with this plugin? #464

Open
@vb

Description

@vb

Initial checklist

Problem

I want to have a system where the author can't render a React component in mdx with the wrong props.

Example

// Component.tsx

export const Component = ({ name, age }: { name: string, age: number }) => {
  return ...
}
import { Component } from './Component'

## Component

<Component name="vb" age={35} /> // ✅
<Component name="vb" />          // ❌ Missing mandatory prop
<Component name={35} age={35} /> // ❌ Wrong type for name

Solution

I'd get an eslint error when I try to render a React component in mdx with bad props

Alternatives

I guess this is done together with plugin:@typescript-eslint?

Metadata

Metadata

Assignees

No one assigned

    Labels

    👀 no/externalThis makes more sense somewhere else👎 phase/noPost cannot or will not be acted on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions