Closed remcohaszing closed 5 months ago
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
mdx | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Jun 25, 2024 7:52pm |
In this PR, I saw the existing code:
// Register MDX nodes in mdast:
/// <reference types="remark-mdx" />
I think we can now change, and recommend @import {} from 'remark-mdx
?
Thanks :)
Initial checklist
Description of changes
Previously we used
@typedef
tags to simulate type imports. The problem is that are not really imports. They define and export a new type. We now use@import
introduced by TypeScript 5.5 to actually import types.The pattern using
@typedef
is still used in index files to export types.This change also replaces the type casting inside MDX files with definitions of the
Props
types.This also replaces usage of the global
JSX
namespace with proper types. For TypeScript<5.1 the correct return type of React components isReactElement
, for PreactVNode
. For TypeScript>=5.1, the correct return type for React components isReactNode
, for PreactComponentChildren
.ReactElement
/VNode
and are compatible with TypeScript>=5.1. This is why those are used for public facing APIs, butReactNode
/ComponentChildren
is used for internal components.