refactor: make entire project typecheck with root tsconfig (#7466)

This commit is contained in:
Joshua Chen 2022-05-23 12:54:25 +08:00 committed by GitHub
parent 89b0fff128
commit 2d94d575a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 74 additions and 36 deletions

View file

@ -67,9 +67,10 @@ const APITableRowComp = React.forwardRef(APITableRow);
* should be generally correct in the MDX context.
*/
export default function APITable({children, name}: Props): JSX.Element {
const [thead, tbody] = React.Children.toArray(
children.props.children,
) as ReactElement[];
const [thead, tbody] = React.Children.toArray(children.props.children) as [
ReactElement,
ReactElement,
];
const highlightedRow = useRef<HTMLTableRowElement>(null);
useEffect(() => {
highlightedRow.current?.focus();

View file

@ -250,7 +250,7 @@ export default function ColorGenerator(): JSX.Element {
setShades({
...shades,
[variableName]: {
...shades[variableName],
...shades[variableName]!,
adjustmentInput: event.target.value,
adjustment: Number.isNaN(newValue)
? adjustment

View file

@ -23,7 +23,7 @@ function PackageJson() {
// Only happens in deploy preview / local dev, but still nice
const versionName =
latestVersion.name === 'current' && allVersions.length > 1
? allVersions[1].name
? allVersions[1]!.name
: latestVersion.name;
return (
<CodeBlock language="json" title="package.json">{`{

View file

@ -101,7 +101,7 @@ function MigrationAnnouncement() {
function TweetsSection() {
const tweetColumns: Array<Array<TweetItem>> = [[], [], []];
Tweets.filter((tweet) => tweet.showOnHomepage).forEach((tweet, i) =>
tweetColumns[i % 3].push(tweet),
tweetColumns[i % 3]!.push(tweet),
);
return (

10
website/src/theme/theme.d.ts vendored Normal file
View file

@ -0,0 +1,10 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
declare module '@theme-original/ColorModeToggle' {
export {default} from '@theme/ColorModeToggle';
}

View file

@ -85,12 +85,14 @@ export const darkStorage = createStorageSlot('ifm-theme-colors-dark', {
persistence: 'sessionStorage',
});
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export function getAdjustedColors(shades: Shades, baseColor: string) {
export function getAdjustedColors(
shades: Shades,
baseColor: string,
): (Shades[string] & {variableName: string; hex: string})[] {
return Object.keys(shades).map((shade) => ({
...shades[shade],
...shades[shade]!,
variableName: shade,
hex: Color(baseColor).darken(shades[shade].adjustment).hex(),
hex: Color(baseColor).darken(shades[shade]!.adjustment).hex(),
}));
}