Skip to content

Commit

Permalink
Convert sample suite to TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmaj committed Apr 5, 2023
1 parent c2d2a59 commit 2198221
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 4 deletions.
4 changes: 2 additions & 2 deletions sample/Sample.jsx → sample/Sample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'react-calendar/dist/Calendar.css';
import './Sample.css';

export default function Sample() {
const [value, onChange] = useState(new Date());
const [value, onChange] = useState<Date | null | (Date | null)[]>(new Date());

return (
<div className="Sample">
Expand All @@ -14,7 +14,7 @@ export default function Sample() {
</header>
<div className="Sample__container">
<main className="Sample__container__content">
<Calendar onChange={onChange} showWeekNumbers value={value} />
<Calendar onChange={(nextValue) => onChange(nextValue)} showWeekNumbers value={value} />
</main>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion sample/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
</head>
<body>
<div id="react-root"></div>
<script type="module" src="./index.jsx"></script>
<script type="module" src="./index.tsx"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion sample/index.jsx → sample/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import React from 'react';
import { createRoot } from 'react-dom/client';
import Sample from './Sample';

createRoot(document.getElementById('react-root')).render(<Sample />);
createRoot(document.getElementById('react-root') as HTMLDivElement).render(<Sample />);
14 changes: 14 additions & 0 deletions sample/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"compilerOptions": {
"declaration": true,
"esModuleInterop": true,
"isolatedModules": true,
"jsx": "react",
"moduleResolution": "node",
"noUncheckedIndexedAccess": true,
"outDir": "dist",
"strict": true,
"strictNullChecks": true,
"target": "es5"
}
}
File renamed without changes.

0 comments on commit 2198221

Please sign in to comment.