@@ -48,7 +48,7 @@ const images = {
48
48
49
49
const scope = {
50
50
...themeUI ,
51
- Link : ( props ) => {
51
+ Link : ( props : Record < string , any > ) => {
52
52
if ( props . activeClassName )
53
53
return < span className = { props . activeClassName } { ...props } />
54
54
return < span { ...props } sx = { { cursor : 'pointer' } } />
@@ -57,20 +57,28 @@ const scope = {
57
57
images,
58
58
}
59
59
60
- const stripTrailingNewline = ( str ) => {
60
+ const stripTrailingNewline = ( str : string ) => {
61
61
if ( typeof str === 'string' && str [ str . length - 1 ] === '\n' ) {
62
62
return str . slice ( 0 , - 1 )
63
63
}
64
64
return str
65
65
}
66
66
67
- const transformCode = ( src ) => {
67
+ const transformCode = ( src : string ) => {
68
68
return `<>${ src } </>`
69
69
}
70
70
71
71
const liveTheme : PrismTheme = { plain : { } , styles : [ ] }
72
72
73
- export const LiveCode = ( { children, preview, xray } ) => {
73
+ export const LiveCode = ( {
74
+ children,
75
+ preview,
76
+ xray,
77
+ } : {
78
+ children : string
79
+ preview ?: boolean
80
+ xray ?: boolean
81
+ } ) => {
74
82
const code = stripTrailingNewline ( children )
75
83
76
84
if ( preview ) {
@@ -96,8 +104,8 @@ export const LiveCode = ({ children, preview, xray }) => {
96
104
< div
97
105
sx = { {
98
106
p : 3 ,
99
- variant : xray ? 'styles.xray' : null ,
100
- border : ( t ) => `1px solid ${ t . colors . muted } ` ,
107
+ variant : xray ? 'styles.xray' : undefined ,
108
+ border : ( t ) => `1px solid ${ t . colors ! . muted } ` ,
101
109
} }
102
110
>
103
111
< LivePreview />
@@ -114,6 +122,7 @@ export const LiveCode = ({ children, preview, xray }) => {
114
122
</ div >
115
123
< Themed . pre sx = { { p : 0 , mt : 0 , mb : 3 } } >
116
124
< LiveEditor
125
+ // @ts -expect-error
117
126
padding = "1rem"
118
127
style = { {
119
128
fontFamily : 'inherit' ,
@@ -134,17 +143,18 @@ type UsualCodeBlockProps = {
134
143
type CodeBlockProps = LiveCodeBlockProps | UsualCodeBlockProps
135
144
136
145
const CodeBlock = ( props : CodeBlockProps ) => {
137
- if ( typeof props . children === 'object' ) {
146
+ if ( typeof props . children === 'object' && props . children ) {
138
147
props = {
139
148
...props ,
140
- ...props . children . props ,
149
+ ...( props . children as any ) . props ,
141
150
}
142
151
}
143
152
144
153
if ( props . live ) {
145
154
return (
146
155
< LiveCode
147
156
{ ...props }
157
+ // @ts -expect-error
148
158
style = { {
149
159
fontFamily : 'Menlo' ,
150
160
} }
0 commit comments