Skip to content

Commit

Permalink
docs: add type assertion to React.JSX.Element type
Browse files Browse the repository at this point in the history
  • Loading branch information
karlhorky authored Dec 16, 2024
1 parent b28cf13 commit 7cd14d8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions docs/packages/next.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ You can also call `codeToHast` to get the HTML abstract syntax tree, and render
```tsx
import type { BundledLanguage } from 'shiki'
import { toJsxRuntime } from 'hast-util-to-jsx-runtime'
import type { JSX } from 'react'

Check failure on line 54 in docs/packages/next.md

View workflow job for this annotation

GitHub Actions / lint

Expected "react" (type) to come before "hast-util-to-jsx-runtime" (external)
import { Fragment } from 'react'
import { jsx, jsxs } from 'react/jsx-runtime'
import { codeToHast } from 'shiki'
Expand Down Expand Up @@ -87,7 +88,7 @@ async function CodeBlock(props: Props) {
// your custom `pre` element
pre: props => <pre data-custom-codeblock {...props} />
},
})
}) as JSX.Element
}
```

Expand All @@ -101,6 +102,7 @@ Create a `shared.ts` for highlighter:
```ts
import type { BundledLanguage } from 'shiki/bundle/web'
import { toJsxRuntime } from 'hast-util-to-jsx-runtime'
import type { JSX } from 'react'

Check failure on line 105 in docs/packages/next.md

View workflow job for this annotation

GitHub Actions / lint

Expected "react" (type) to come before "hast-util-to-jsx-runtime" (external)
import { Fragment } from 'react'
import { jsx, jsxs } from 'react/jsx-runtime'
import { codeToHast } from 'shiki/bundle/web'
Expand All @@ -115,7 +117,7 @@ export async function highlight(code: string, lang: BundledLanguage) {
Fragment,
jsx,
jsxs,
})
}) as JSX.Element
}
```

Expand Down

0 comments on commit 7cd14d8

Please sign in to comment.