chore: fix tsc (#45352)

This commit is contained in:
MadCcc 2023-10-15 19:17:32 +08:00 committed by GitHub
parent bfa9addfce
commit 04cc086fb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 18 additions and 11 deletions

View File

@ -1,6 +1,6 @@
import { startTransition, useState } from 'react';
const useLayoutState = <S>(
const useLayoutState: typeof useState = <S>(
...args: Parameters<typeof useState<S>>
): ReturnType<typeof useState<S>> => {
const [state, setState] = useState<S>(...args);

View File

@ -101,7 +101,7 @@ export default function ThemePicker(props: ThemePickerProps) {
onChange?.(theme);
}}
>
<input type="radio" name="theme" id={index === 0 ? id : null} />
<input type="radio" name="theme" id={index === 0 ? id : undefined} />
<img src={url} alt={theme} />
</label>
<span>{locale[theme as keyof typeof locale]}</span>

View File

@ -2,7 +2,7 @@ import React from 'react';
import { Global, css } from '@emotion/react';
import { useTheme } from 'antd-style';
const gray = {
const gray: { [key: number]: string } = {
1: '#fff',
2: '#fafafa',
3: '#f5f5f5',
@ -25,7 +25,7 @@ const ColorStyle = () => {
if (index <= 10) {
return `
.palette-${color}-${index} {
background: ${token[`${color}-${index}`]};
background: ${(token as any)[`${color}-${index}`]};
}
${makePalette(color, index + 1)}
`;

View File

@ -7,7 +7,7 @@ const ltrD =
const rtlD =
'M256 64l512 0 0 128-128 0 0 768-128 0 0-768-128 0 0 768-128 0 0-448c-123.712 0-224-100.288-224-224s100.288-224 224-224zM960 896l-256-224 256-224z';
const DirectionIcon: React.FC<{ direction: DirectionType }> = (props) => (
const DirectionIcon: React.FC<{ direction: DirectionType; className?: string }> = (props) => (
<Icon {...props}>
<svg viewBox="0 0 1024 1024" fill="currentColor">
<path d={props.direction === 'ltr' ? ltrD : rtlD} />

View File

@ -45,7 +45,7 @@ const getAlgorithm = (themes: ThemeName[] = []) =>
}
return null;
})
.filter((item) => item);
.filter((item) => item) as typeof antdTheme.darkAlgorithm[];
const GlobalLayout: React.FC = () => {
const outlet = useOutlet();
@ -109,7 +109,7 @@ const GlobalLayout: React.FC = () => {
setSiteState({
theme: _theme,
direction: _direction === 'rtl' ? 'rtl' : 'ltr',
bannerVisible: storedBannerVisibleLastTime ? storedBannerVisible : true,
bannerVisible: storedBannerVisibleLastTime ? !!storedBannerVisible : true,
});
// Handle isMobile
updateMobileMode();

View File

@ -57,7 +57,7 @@ const AffixTabs: React.FC = () => {
const containerRef = React.useRef<HTMLDivElement>(null);
const idsRef = React.useRef<string[]>([]);
const [loaded, setLoaded] = React.useState(false);
const [fixedId, setFixedId] = React.useState<string | null>(null);
const [fixedId, setFixedId] = React.useState<string | undefined>(undefined);
const {
styles: { affixTabs, affixTabsFixed, span },
@ -100,7 +100,7 @@ const AffixTabs: React.FC = () => {
}
}
setFixedId(null);
setFixedId(undefined);
}
return throttle(doSync);

View File

@ -37,7 +37,7 @@ const Community: React.FC = () => {
);
};
export const getEcosystemGroup = (): MenuProps['items'] => [
export const getEcosystemGroup = (): Exclude<MenuProps['items'], undefined> => [
{
label: (
<a href="https://charts.ant.design" target="_blank" rel="noopener noreferrer">

View File

@ -215,7 +215,8 @@ export default ({
label: (
<Link
to={utils.getLocalizedPathname(
blogList.sort((a, b) => (a.frontmatter.date > b.frontmatter.date ? -1 : 1))[0].link,
blogList.sort((a, b) => (a.frontmatter?.date > b.frontmatter?.date ? -1 : 1))[0]
.link,
isZhCN,
search,
)}

View File

@ -11,6 +11,7 @@ export interface LangBtnProps {
value: 1 | 2;
pure?: boolean;
onClick?: React.MouseEventHandler;
['aria-label']?: string;
}
const BASE_SIZE = '1.2em';

View File

@ -30,6 +30,11 @@ const locales = {
shortMessage: '支付宝语雀 · 大学生公益计划火热进行中!',
more: '了解更多',
},
en: {
message: '',
shortMessage: '',
more: '',
},
};
const useStyle = createStyles(({ token, css }) => {