Skip to content

Commit 7f78cd5

Browse files
authored
chore(docs): add strict mode to website (#1911)
1 parent 2121ac3 commit 7f78cd5

File tree

6 files changed

+11
-10
lines changed

6 files changed

+11
-10
lines changed

website/examples/date-picker-dialog.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { ChangeEventHandler, useRef, useState } from 'react';
22

33
import { format, isValid, parse } from 'date-fns';
44
import FocusTrap from 'focus-trap-react';
5-
import { DayPicker } from 'react-day-picker';
5+
import { DayPicker, SelectSingleEventHandler } from 'react-day-picker';
66
import { usePopper } from 'react-popper';
77

88
export default function DatePickerDialog() {
@@ -39,7 +39,7 @@ export default function DatePickerDialog() {
3939
setIsPopperOpen(true);
4040
};
4141

42-
const handleDaySelect = (date: Date) => {
42+
const handleDaySelect: SelectSingleEventHandler = (date) => {
4343
setSelected(date);
4444
if (date) {
4545
setInputValue(format(date, 'y-MM-dd'));
@@ -76,7 +76,7 @@ export default function DatePickerDialog() {
7676
allowOutsideClick: true,
7777
clickOutsideDeactivates: true,
7878
onDeactivate: closePopper,
79-
fallbackFocus: buttonRef.current
79+
fallbackFocus: buttonRef.current || undefined
8080
}}
8181
>
8282
<div

website/examples/testcase-1567.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { DateRange, DayPicker } from 'react-day-picker';
88
* @see https://github.com/gpbl/react-day-picker/issues/1567
99
*/
1010
export default function App() {
11-
const [selected, setSelected] = useState<DateRange>({
11+
const [selected, setSelected] = useState<DateRange | undefined>({
1212
from: new Date(2022, 8, 25),
1313
to: new Date(2022, 9, 1)
1414
});

website/src/pages/render.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default function Render(): JSX.Element {
2626
display: 'inline-block',
2727
padding: '1em'
2828
}}
29-
name={name}
29+
name={name || 'date-picker'}
3030
/>
3131
);
3232
}}

website/src/theme/CodeBlock/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default function CodeBlockWithSandpack(props: {
3333
const fileName = props.children.replace(/\n*/gi, '');
3434
const src = require(`!!raw-loader!@site/examples/${fileName}`)
3535
.default as string;
36-
const dependencies: Record<string, string> = props.dependencies
36+
const dependencies: Record<string, string> | undefined = props.dependencies
3737
?.split(',')
3838
.reduce(
3939
(result, dependency) => ({ ...result, [dependency]: 'latest' }),
@@ -52,7 +52,7 @@ export default function CodeBlockWithSandpack(props: {
5252
title="Open the rendered example in a new window."
5353
onClick={() => {
5454
const win = window.open(`/render?example=${fileName}`, '_blank');
55-
win.focus();
55+
win?.focus();
5656
}}
5757
>
5858
New Window ↗

website/test-integration/examples/spanish-week-starts-on.test.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ freezeBeforeAll(today);
1313
beforeEach(() => render(<Example />));
1414

1515
test('should have "Domingo" as first day of week', () => {
16-
expect(getMonthGrid().firstChild.firstChild.firstChild).toHaveAccessibleName(
17-
'domingo'
18-
);
16+
expect(
17+
getMonthGrid().firstChild?.firstChild?.firstChild
18+
).toHaveAccessibleName('domingo');
1919
});

website/tsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"extends": "@tsconfig/docusaurus/tsconfig.json",
33
"compilerOptions": {
4+
"strict": true,
45
"jsx": "react",
56
"baseUrl": ".",
67
"lib": ["es2019", "DOM"],

0 commit comments

Comments
 (0)