Skip to content

Commit

Permalink
Add section on types
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Sep 29, 2021
1 parent 59701d5 commit abcac7b
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ Node 12+ is needed to use it and it must be `import`ed instead of `require`d.
* [Footnotes](#footnotes)
* [Frontmatter](#frontmatter)
* [Plugins](#plugins)
* [Types](#types)
* [Differences from `@mdx-js/mdx`](#differences-from-mdx-jsmdx)
* [Architecture](#architecture)
* [Security](#security)
Expand Down Expand Up @@ -2172,6 +2173,34 @@ None yet!
* [`remark-mdx-frontmatter`](https://github.com/remcohaszing/remark-mdx-frontmatter)
— change frontmatter (YAML) metadata to exports

## Types

This package is fully typed with [TypeScript](https://www.typescriptlang.org).

To enable types for imported `.mdx`, `.md`, etcetera files, first make sure
the TypeScript `JSX` namespace is typed (such as by importing the `react`
types), and then import `xdm/registry`.

```js
/**
* @typedef {import('react')} */
* @typedef {import('xdm/registry')} */
*/

import Post from './example.mdx'
// `Post` is now typed.
```

Alternatively, in TypeScript, do:

```ts
/// <reference types="react" />
/// <reference types="xdm/registry" />

import Post from './example.mdx'
// `Post` is now typed.
```

## Differences from `@mdx-js/mdx`

**API** (build):
Expand Down

0 comments on commit abcac7b

Please sign in to comment.