Skip to content

Commit

Permalink
chore: fix tsc (#45352)
Browse files Browse the repository at this point in the history
  • Loading branch information
MadCcc committed Oct 15, 2023
1 parent bfa9add commit 04cc086
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .dumi/hooks/useLayoutState.ts
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
2 changes: 1 addition & 1 deletion .dumi/pages/index/components/Theme/ThemePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
4 changes: 2 additions & 2 deletions .dumi/theme/common/Color/ColorStyle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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)}
`;
Expand Down
2 changes: 1 addition & 1 deletion .dumi/theme/common/DirectionIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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} />
Expand Down
4 changes: 2 additions & 2 deletions .dumi/theme/layouts/GlobalLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions .dumi/theme/layouts/ResourceLayout/AffixTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down Expand Up @@ -100,7 +100,7 @@ const AffixTabs: React.FC = () => {
}
}

setFixedId(null);
setFixedId(undefined);
}

return throttle(doSync);
Expand Down
2 changes: 1 addition & 1 deletion .dumi/theme/slots/Header/More.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
3 changes: 2 additions & 1 deletion .dumi/theme/slots/Header/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)}
Expand Down
1 change: 1 addition & 0 deletions .dumi/theme/slots/Header/SwitchBtn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface LangBtnProps {
value: 1 | 2;
pure?: boolean;
onClick?: React.MouseEventHandler;
['aria-label']?: string;
}

const BASE_SIZE = '1.2em';
Expand Down
5 changes: 5 additions & 0 deletions .dumi/theme/slots/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ const locales = {
shortMessage: '支付宝语雀 · 大学生公益计划火热进行中!',
more: '了解更多',
},
en: {
message: '',
shortMessage: '',
more: '',
},
};

const useStyle = createStyles(({ token, css }) => {
Expand Down

1 comment on commit 04cc086

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.