Skip to content

Commit

Permalink
chore(docs): add strict mode to website (#1911)
Browse files Browse the repository at this point in the history
  • Loading branch information
gpbl authored Sep 23, 2023
1 parent 2121ac3 commit 7f78cd5
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
6 changes: 3 additions & 3 deletions website/examples/date-picker-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { ChangeEventHandler, useRef, useState } from 'react';

import { format, isValid, parse } from 'date-fns';
import FocusTrap from 'focus-trap-react';
import { DayPicker } from 'react-day-picker';
import { DayPicker, SelectSingleEventHandler } from 'react-day-picker';
import { usePopper } from 'react-popper';

export default function DatePickerDialog() {
Expand Down Expand Up @@ -39,7 +39,7 @@ export default function DatePickerDialog() {
setIsPopperOpen(true);
};

const handleDaySelect = (date: Date) => {
const handleDaySelect: SelectSingleEventHandler = (date) => {
setSelected(date);
if (date) {
setInputValue(format(date, 'y-MM-dd'));
Expand Down Expand Up @@ -76,7 +76,7 @@ export default function DatePickerDialog() {
allowOutsideClick: true,
clickOutsideDeactivates: true,
onDeactivate: closePopper,
fallbackFocus: buttonRef.current
fallbackFocus: buttonRef.current || undefined
}}
>
<div
Expand Down
2 changes: 1 addition & 1 deletion website/examples/testcase-1567.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { DateRange, DayPicker } from 'react-day-picker';
* @see https://github.com/gpbl/react-day-picker/issues/1567
*/
export default function App() {
const [selected, setSelected] = useState<DateRange>({
const [selected, setSelected] = useState<DateRange | undefined>({
from: new Date(2022, 8, 25),
to: new Date(2022, 9, 1)
});
Expand Down
2 changes: 1 addition & 1 deletion website/src/pages/render.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default function Render(): JSX.Element {
display: 'inline-block',
padding: '1em'
}}
name={name}
name={name || 'date-picker'}
/>
);
}}
Expand Down
4 changes: 2 additions & 2 deletions website/src/theme/CodeBlock/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default function CodeBlockWithSandpack(props: {
const fileName = props.children.replace(/\n*/gi, '');
const src = require(`!!raw-loader!@site/examples/${fileName}`)
.default as string;
const dependencies: Record<string, string> = props.dependencies
const dependencies: Record<string, string> | undefined = props.dependencies
?.split(',')
.reduce(
(result, dependency) => ({ ...result, [dependency]: 'latest' }),
Expand All @@ -52,7 +52,7 @@ export default function CodeBlockWithSandpack(props: {
title="Open the rendered example in a new window."
onClick={() => {
const win = window.open(`/render?example=${fileName}`, '_blank');
win.focus();
win?.focus();
}}
>
New Window ↗
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ freezeBeforeAll(today);
beforeEach(() => render(<Example />));

test('should have "Domingo" as first day of week', () => {
expect(getMonthGrid().firstChild.firstChild.firstChild).toHaveAccessibleName(
'domingo'
);
expect(
getMonthGrid().firstChild?.firstChild?.firstChild
).toHaveAccessibleName('domingo');
});
1 change: 1 addition & 0 deletions website/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": "@tsconfig/docusaurus/tsconfig.json",
"compilerOptions": {
"strict": true,
"jsx": "react",
"baseUrl": ".",
"lib": ["es2019", "DOM"],
Expand Down

0 comments on commit 7f78cd5

Please sign in to comment.