Skip to content

Commit

Permalink
Fix typescript errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Hal-9k1 committed Nov 29, 2024
1 parent 7841683 commit 0d64fae
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 10 deletions.
12 changes: 11 additions & 1 deletion src/renderer/editor/ApiLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import './ApiLink.css';
* Links to a section of the student API documentation, opening the help window or just jumping to
* the appropriate section if the window is already open. The single text node child of this
* component is used as the link text.
* @param props
* @param props.dest - the section of the docs to jump to. TODO: figure out format
* @param props.code - whether to display the link text in a monospaced font.
*/
export default function ApiLink({
dest,
code = false,
code,
children,
}: {
dest: string;
Expand All @@ -24,3 +25,12 @@ export default function ApiLink({
</button>
);
}
/**
* Default props for ApiLink.
*/
ApiLink.defaultProps = {
/**
* By default, link text is displayed in the inherited font.
*/
code: false,

Check failure on line 35 in src/renderer/editor/ApiLink.tsx

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

defaultProp "code" defined for isRequired propType
};
16 changes: 13 additions & 3 deletions src/renderer/editor/HighlightedCode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ import './HighlightedCode.css';
* valid children of this component is text containing the code to be displayed. Common indentation
* is removed from each line of code before display. Only spaces are considered indentation; tabs,
* half-width spaces, and nonbreaking spaces are treated as content.
* @param props
* @param props.indent - number of spaces of indentation to prepend to each line, after common
* indentation is removed.
*/
export default function HighlightedCode({
children,
indent = 0,
indent,
}: {
children: string;
indent: number?;
indent: number;

Check failure on line 19 in src/renderer/editor/HighlightedCode.tsx

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

propType "indent" is required and should not have a defaultProps declaration
}) {
const lines = children.split('\n');
if (lines.length && !lines[0].trim()) {
Expand All @@ -28,7 +29,7 @@ export default function HighlightedCode({
const minIndent = Math.min(
...lines
.filter((line) => line.trim().length)
.map((line) => line.match(/^ */)[0].length),
.map((line) => line.match(/^ */)![0].length),
);
const formatted = lines
.map((line) => ' '.repeat(indent) + line.slice(minIndent))
Expand All @@ -45,3 +46,12 @@ export default function HighlightedCode({
/>
);
}
/**
* Default props for HighlightedCode.
*/
HighlightedCode.defaultProps = {
/**
* No indentation is added to code lines after stripping common indentation by default.
*/
indent: 0,

Check failure on line 56 in src/renderer/editor/HighlightedCode.tsx

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

defaultProp "indent" defined for isRequired propType
};
7 changes: 3 additions & 4 deletions src/renderer/modals/ConfirmModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ export default function ConfirmModal({
onConfirm,
isActive,
modalTitle,
noAutoClose = false,
noAutoClose,
children,
}: {
onClose: () => void;
onConfirm: () => void;
isActive: boolean;
modalTitle: string;
noAutoClose?: boolean;
noAutoClose: boolean;

Check failure on line 26 in src/renderer/modals/ConfirmModal.tsx

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

propType "noAutoClose" is required and should not have a defaultProps declaration
children: ReactNode;
}) {
const handleConfirm = () => {
Expand All @@ -46,8 +46,7 @@ export default function ConfirmModal({
);
}
/**
* Default properties for ConfirmModal. Not sure why we need this if we have the default
* deconstruction parameter but the linter cries if we leave it out.
* Default properties for ConfirmModal.
*/
ConfirmModal.defaultProps = {
/**
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/modals/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ export default function Modal({
isActive,
modalTitle,
children,
className = '',
className,
}: {
onClose: () => void;
isActive: boolean;
modalTitle: string;
children: ReactNode;
className?: string;
className: string;

Check failure on line 23 in src/renderer/modals/Modal.tsx

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

propType "className" is required and should not have a defaultProps declaration
}) {
return (
<div className={`Modal${isActive ? ' Modal-active' : ''}`}>
Expand Down

0 comments on commit 0d64fae

Please sign in to comment.