mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-28 22:18:44 +02:00
refactor: fix a lot of errors in type-aware linting (#7477)
This commit is contained in:
parent
222bf3c091
commit
bf1513a3e3
120 changed files with 407 additions and 364 deletions
|
@ -68,8 +68,8 @@ const APITableRowComp = React.forwardRef(APITableRow);
|
|||
*/
|
||||
export default function APITable({children, name}: Props): JSX.Element {
|
||||
const [thead, tbody] = React.Children.toArray(children.props.children) as [
|
||||
ReactElement,
|
||||
ReactElement,
|
||||
ReactElement<{children: ReactElement[]}>,
|
||||
ReactElement<{children: ReactElement[]}>,
|
||||
];
|
||||
const highlightedRow = useRef<HTMLTableRowElement>(null);
|
||||
useEffect(() => {
|
||||
|
|
|
@ -59,7 +59,9 @@ export default function ColorGenerator(): JSX.Element {
|
|||
|
||||
// Switch modes -> update state by stored values
|
||||
useEffect(() => {
|
||||
const storedValues: ColorState = JSON.parse(storage.get() ?? '{}');
|
||||
const storedValues = JSON.parse(
|
||||
storage.get() ?? '{}',
|
||||
) as Partial<ColorState>;
|
||||
setInputColor(storedValues.baseColor ?? DEFAULT_PRIMARY_COLOR);
|
||||
setBaseColor(storedValues.baseColor ?? DEFAULT_PRIMARY_COLOR);
|
||||
setBackground(storedValues.background ?? DEFAULT_BACKGROUND_COLOR);
|
||||
|
|
|
@ -12,7 +12,7 @@ import Link from '@docusaurus/Link';
|
|||
function WebsiteLink({to, children}: {to: string; children?: ReactNode}) {
|
||||
return (
|
||||
<Link to={to}>
|
||||
{children || (
|
||||
{children ?? (
|
||||
<Translate id="team.profile.websiteLinkLabel">website</Translate>
|
||||
)}
|
||||
</Link>
|
||||
|
@ -23,7 +23,7 @@ type ProfileProps = {
|
|||
className?: string;
|
||||
name: string;
|
||||
children: ReactNode;
|
||||
githubUrl?: string;
|
||||
githubUrl: string;
|
||||
twitterUrl?: string;
|
||||
};
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ function MigrationAnnouncement() {
|
|||
}
|
||||
|
||||
function TweetsSection() {
|
||||
const tweetColumns: Array<Array<TweetItem>> = [[], [], []];
|
||||
const tweetColumns: TweetItem[][] = [[], [], []];
|
||||
Tweets.filter((tweet) => tweet.showOnHomepage).forEach((tweet, i) =>
|
||||
tweetColumns[i % 3]!.push(tweet),
|
||||
);
|
||||
|
|
|
@ -35,7 +35,7 @@ export default function ShowcaseFilterToggle(): JSX.Element {
|
|||
const searchParams = new URLSearchParams(location.search);
|
||||
searchParams.delete(OperatorQueryKey);
|
||||
if (!operator) {
|
||||
searchParams.append(OperatorQueryKey, operator ? 'OR' : 'AND');
|
||||
searchParams.append(OperatorQueryKey, 'AND');
|
||||
}
|
||||
history.push({
|
||||
...location,
|
||||
|
|
|
@ -14,7 +14,6 @@ interface Props {
|
|||
anchorEl?: HTMLElement | string;
|
||||
id: string;
|
||||
text: string;
|
||||
delay?: number;
|
||||
children: React.ReactElement;
|
||||
}
|
||||
|
||||
|
@ -23,7 +22,6 @@ export default function Tooltip({
|
|||
id,
|
||||
anchorEl,
|
||||
text,
|
||||
delay,
|
||||
}: Props): JSX.Element {
|
||||
const [open, setOpen] = useState(false);
|
||||
const [referenceElement, setReferenceElement] = useState<HTMLElement | null>(
|
||||
|
@ -84,7 +82,7 @@ export default function Tooltip({
|
|||
|
||||
timeout.current = window.setTimeout(() => {
|
||||
setOpen(true);
|
||||
}, delay || 400);
|
||||
}, 400);
|
||||
};
|
||||
|
||||
const handleClose = () => {
|
||||
|
@ -113,7 +111,7 @@ export default function Tooltip({
|
|||
});
|
||||
}
|
||||
};
|
||||
}, [referenceElement, text, delay]);
|
||||
}, [referenceElement, text]);
|
||||
|
||||
return (
|
||||
<>
|
||||
|
|
|
@ -58,38 +58,35 @@ export default function Version(): JSX.Element {
|
|||
</Translate>
|
||||
</Heading>
|
||||
|
||||
{latestVersion && (
|
||||
<div className="margin-bottom--lg">
|
||||
<Heading as="h3" id="next">
|
||||
<Translate id="versionsPage.current.title">
|
||||
Current version (Stable)
|
||||
</Translate>
|
||||
</Heading>
|
||||
<p>
|
||||
<Translate id="versionsPage.current.description">
|
||||
Here you can find the documentation for current released
|
||||
version.
|
||||
</Translate>
|
||||
</p>
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>{latestVersion.label}</th>
|
||||
<td>
|
||||
<Link to={latestVersion.path}>
|
||||
<DocumentationLabel />
|
||||
</Link>
|
||||
</td>
|
||||
<td>
|
||||
<a href={`${repoUrl}/releases/tag/v${latestVersion.name}`}>
|
||||
<ReleaseNotesLabel />
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
)}
|
||||
<div className="margin-bottom--lg">
|
||||
<Heading as="h3" id="next">
|
||||
<Translate id="versionsPage.current.title">
|
||||
Current version (Stable)
|
||||
</Translate>
|
||||
</Heading>
|
||||
<p>
|
||||
<Translate id="versionsPage.current.description">
|
||||
Here you can find the documentation for current released version.
|
||||
</Translate>
|
||||
</p>
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>{latestVersion.label}</th>
|
||||
<td>
|
||||
<Link to={latestVersion.path}>
|
||||
<DocumentationLabel />
|
||||
</Link>
|
||||
</td>
|
||||
<td>
|
||||
<a href={`${repoUrl}/releases/tag/v${latestVersion.name}`}>
|
||||
<ReleaseNotesLabel />
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
{currentVersion !== latestVersion && (
|
||||
<div className="margin-bottom--lg">
|
||||
|
|
|
@ -32,7 +32,9 @@ export default function ColorModeToggle(props: Props): JSX.Element {
|
|||
props.onChange(colorMode);
|
||||
const isDarkMode = colorMode === 'dark';
|
||||
const storage = isDarkMode ? darkStorage : lightStorage;
|
||||
const colorState: ColorState = JSON.parse(storage.get() ?? 'null') ?? {
|
||||
const colorState = (JSON.parse(
|
||||
storage.get() ?? 'null',
|
||||
) as ColorState | null) ?? {
|
||||
baseColor: isDarkMode ? DARK_PRIMARY_COLOR : LIGHT_PRIMARY_COLOR,
|
||||
background: isDarkMode
|
||||
? DARK_BACKGROUND_COLOR
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue