Skip to content

Commit 3b7de6d

Browse files
committed
Fix type errors
1 parent ec98518 commit 3b7de6d

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed

packages/docs/src/components/code.tsx

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const images = {
4848

4949
const scope = {
5050
...themeUI,
51-
Link: (props) => {
51+
Link: (props: Record<string, any>) => {
5252
if (props.activeClassName)
5353
return <span className={props.activeClassName} {...props} />
5454
return <span {...props} sx={{ cursor: 'pointer' }} />
@@ -57,20 +57,28 @@ const scope = {
5757
images,
5858
}
5959

60-
const stripTrailingNewline = (str) => {
60+
const stripTrailingNewline = (str: string) => {
6161
if (typeof str === 'string' && str[str.length - 1] === '\n') {
6262
return str.slice(0, -1)
6363
}
6464
return str
6565
}
6666

67-
const transformCode = (src) => {
67+
const transformCode = (src: string) => {
6868
return `<>${src}</>`
6969
}
7070

7171
const liveTheme: PrismTheme = { plain: {}, styles: [] }
7272

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+
}) => {
7482
const code = stripTrailingNewline(children)
7583

7684
if (preview) {
@@ -96,8 +104,8 @@ export const LiveCode = ({ children, preview, xray }) => {
96104
<div
97105
sx={{
98106
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}`,
101109
}}
102110
>
103111
<LivePreview />
@@ -114,6 +122,7 @@ export const LiveCode = ({ children, preview, xray }) => {
114122
</div>
115123
<Themed.pre sx={{ p: 0, mt: 0, mb: 3 }}>
116124
<LiveEditor
125+
// @ts-expect-error
117126
padding="1rem"
118127
style={{
119128
fontFamily: 'inherit',
@@ -134,17 +143,18 @@ type UsualCodeBlockProps = {
134143
type CodeBlockProps = LiveCodeBlockProps | UsualCodeBlockProps
135144

136145
const CodeBlock = (props: CodeBlockProps) => {
137-
if (typeof props.children === 'object') {
146+
if (typeof props.children === 'object' && props.children) {
138147
props = {
139148
...props,
140-
...props.children.props,
149+
...(props.children as any).props,
141150
}
142151
}
143152

144153
if (props.live) {
145154
return (
146155
<LiveCode
147156
{...props}
157+
// @ts-expect-error
148158
style={{
149159
fontFamily: 'Menlo',
150160
}}

packages/docs/src/components/search-input.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const algoliaStyles: ThemeUICSSObject = {
3333
},
3434
'.algolia-docsearch-suggestion--highlight': {
3535
color: 'primary',
36-
'--shadow-color': (theme) => theme.colors.muted,
36+
'--shadow-color': (theme) => theme.colors!.muted,
3737
boxShadow: 'inset 0 -2px 0 0 var(--shadow-color)',
3838
padding: 0,
3939
},
@@ -78,7 +78,7 @@ const resetButtonStyles: ThemeUICSSObject = {
7878
width: '1em',
7979
borderRadius: '50em',
8080
background: (th) => {
81-
const textColor = (th.rawColors || th.colors).text
81+
const textColor = (th.rawColors || th.colors)!.text
8282
const fill = encodeURIComponent(String(textColor))
8383
return `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'%3E%3Cpath fill='${fill}' d='M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm121.6 313.1c4.7 4.7 4.7 12.3 0 17L338 377.6c-4.7 4.7-12.3 4.7-17 0L256 312l-65.1 65.6c-4.7 4.7-12.3 4.7-17 0L134.4 338c-4.7-4.7-4.7-12.3 0-17l65.6-65-65.6-65.1c-4.7-4.7-4.7-12.3 0-17l39.6-39.6c4.7-4.7 12.3-4.7 17 0l65 65.7 65.1-65.6c4.7-4.7 12.3-4.7 17 0l39.6 39.6c4.7 4.7 4.7 12.3 0 17L312 256l65.6 65.1z'/%3E%3C/svg%3E");`
8484
},
@@ -107,7 +107,7 @@ export default function SearchInput() {
107107
const searchInputId = 'algolia-docs-search'
108108

109109
useEffect(() => {
110-
let lastSearchInput = null
110+
let lastSearchInput: HTMLElement | null = null
111111
const observer = new MutationObserver(function () {
112112
const searchInput = document.getElementById(searchInputId)
113113
const docsearch = (window as any).docsearch

packages/docs/src/components/sidenav.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ export const AccordionNav = forwardRef<HTMLDivElement, AccordionNavProps>(
277277
<NavLinks
278278
open={pathname.includes(href) || expanded[i]}
279279
Link={Link}
280-
links={children}
280+
links={children!}
281281
/>
282282
</li>
283283
))}

0 commit comments

Comments
 (0)