Skip to content

Commit

Permalink
Fix strict checks
Browse files Browse the repository at this point in the history
  • Loading branch information
KrofDrakula committed May 5, 2023
1 parent a74901b commit c7ba103
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
2 changes: 2 additions & 0 deletions demo/components/code.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const Code: FunctionalComponent<Props> = ({
children,
}) => {
useLayoutEffect(() => {
if (!ref.current) return;
ref.current.textContent = children;
Prism.highlightElement(ref.current);
});
Expand All @@ -23,6 +24,7 @@ const Code: FunctionalComponent<Props> = ({

return (
<pre style="border-radius: 8px">
{/* @ts-ignore */}
<code ref={ref} class={`language-${language}`}>
{children}
</code>
Expand Down
10 changes: 7 additions & 3 deletions demo/components/display.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,18 @@ ${blocks}});
`;
};

type NonNull<T> = T extends null ? never : T;

type Parseable = "text" | "json" | undefined;

const Display: FunctionalComponent = () => {
const [animate, setAnimate] = useState(true);
const [parse, setParse] = useState(undefined);
const [parse, setParse] = useState<Parseable>(undefined);
const [filePicker, setFilePicker] = useState(true);

const handleRadio = useCallback(
(ev: Parameters<HTMLInputElement["oninput"]>[0]) => {
const value = (ev.target as HTMLInputElement).value;
(ev: Parameters<NonNull<HTMLInputElement["oninput"]>>[0]) => {
const value = (ev.target as HTMLInputElement).value as Parseable;
setParse(value ? value : undefined);
},
[]
Expand Down
1 change: 1 addition & 0 deletions demo/components/drop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const Drop: FunctionalComponent<Props> = ({ animate, parse, filePicker }) => {

return (
<>
{/* @ts-ignore */}
<div ref={container} class={styles.drop}>
<div>Drop files here</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion demo/components/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const Preview = <T,>({ files, onClose }: Props<T>): JSX.Element => {
ev.preventDefault();
setActive(name);
}}
class={active == name ? styles.active : null}
class={active == name ? styles.active : undefined}
>
{name}
</a>
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
"jsx": "react-jsx",
"jsxImportSource": "preact"
},
"include": ["src", "examples"]
"include": ["src", "demo", "examples"]
}

0 comments on commit c7ba103

Please sign in to comment.