@@ -8,16 +8,18 @@ import {
88 BrightComponents ,
99 BrightProps ,
1010 Extension ,
11+ CodeText ,
1112} from "./types"
1213import { linesToContent } from "./lines"
1314import { tokensToContent , tokensToTokenList } from "./tokens"
14- import React from "react"
15+ import React , { FunctionComponent } from "react"
1516import "server-only"
1617
1718type CodeComponent = ( ( props : InputCodeProps ) => Promise < JSX . Element > ) &
18- Partial < InputCodeProps >
19+ Partial < InputCodeProps > &
20+ FunctionComponent < InputCodeProps > // this is a lie, until we have typescript 5.1
1921
20- const Code : CodeComponent = async ( componentProps ) => {
22+ const Code = ( async ( componentProps ) => {
2123 // merge props and global props
2224 const { children, lang, ...rest } = {
2325 ...Code ,
@@ -26,7 +28,7 @@ const Code: CodeComponent = async (componentProps) => {
2628 }
2729
2830 // parse code, lang, subProps maybe from markdown
29- const propsFromChildren = parseChildren ( children , lang , rest . code )
31+ const propsFromChildren = parseChildren ( children as CodeText , lang , rest . code )
3032
3133 // split code and annotations
3234 let props = { ...rest , ...propsFromChildren }
@@ -62,7 +64,7 @@ const Code: CodeComponent = async (componentProps) => {
6264 />
6365 </ >
6466 )
65- }
67+ } ) as CodeComponent
6668
6769async function AnnotatedCode ( props : CodeProps ) {
6870 let newProps = await extractAnnotationsFromCode ( props )
@@ -176,8 +178,8 @@ function runExtensionsBeforeHighlight(props: CodeProps): CodeProps {
176178}
177179
178180function parseChildren (
179- children : InputCodeProps [ "children" ] ,
180- lang : LanguageAlias ,
181+ children : CodeText ,
182+ lang ? : LanguageAlias ,
181183 code ?: string
182184) : Partial < BrightProps > {
183185 if ( typeof children === "object" && children ?. type === "code" ) {
0 commit comments