Skip to content

Type-check components in Markdown with TypeScript 7.1 #548

Open

Description

@onmax

TypeScript 7.1 added content mappers, so tsc and the editor can check files that aren't TypeScript. I wrote one for Comark. You declare your components' props and slots on comark's types, and a mistake in a .md file becomes a type error on its line.

content/mistakes.md(6,9): error TS2322: Type '"warn"' is not assignable to type '"danger" | "info" | "warning"'.
content/mistakes.md(19,3): error TS2339: Property 'callout' does not exist on type 'ComarkComponents'.

The playground runs the same check in the browser and can fix most mistakes in one click:
https://comark-playground.maximogarciamtnez.workers.dev/play?example=types

The playground's type check example, with five mistakes underlined and listed with their fixes

The code is on onmax/comark@feat/content-mapper, with a PR at onmax#1. Would you want it here as @comark/content-mapper, or should it live somewhere else?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions