Skip to content

Commit c6ea01a

Browse files
Fix TypeScript compiler issues
1 parent 5c6e5b2 commit c6ea01a

File tree

4 files changed

+21
-19
lines changed

4 files changed

+21
-19
lines changed

.storybook/manager.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@ import { addons } from '@storybook/manager-api';
22
import nhsTheme from './theme';
33
import { startCase, upperFirst } from 'lodash';
44

5-
const sentenceCase = (string) => {
6-
if (typeof string !== 'string') return '';
7-
return upperFirst(startCase(string).toLowerCase());
5+
const sentenceCase = (name = '') => {
6+
if (!name || typeof name !== 'string') {
7+
return '';
8+
}
9+
10+
return upperFirst(startCase(name).toLowerCase());
811
};
912

1013
addons.setConfig({

src/components/navigation/card/components/CardGroupItem.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import classNames from 'classnames';
2-
import { Col } from '#components/layout';
2+
import { type FC } from 'react';
3+
import { Col, type ColProps } from '#components/layout';
34

4-
export const CardGroupItem: typeof Col = ({ className, ...rest }) => (
5+
export const CardGroupItem: FC<ColProps> = ({ className, ...rest }) => (
56
<Col className={classNames('nhsuk-card-group__item', className)} {...rest} />
67
);
78

src/util/types/LinkTypes.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1-
import { type AnchorHTMLAttributes, type ButtonHTMLAttributes, type ElementType } from 'react';
1+
import {
2+
type AnchorHTMLAttributes,
3+
type ButtonHTMLAttributes,
4+
type ElementType,
5+
type PropsWithChildren,
6+
} from 'react';
27

38
export type AsElementLink<T extends HTMLElement> = (T extends HTMLButtonElement
49
? ButtonHTMLAttributes<T>
5-
: AnchorHTMLAttributes<T>) & {
6-
asElement?: ElementType;
7-
to?: string;
8-
};
10+
: AnchorHTMLAttributes<T>) &
11+
PropsWithChildren<{
12+
asElement?: ElementType;
13+
to?: string;
14+
}>;

src/util/types/TypeGuards.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,7 @@ import { type CardType, type CareCardType } from './NHSUKTypes';
1212
* Assert that a child item is of the given component type.
1313
*/
1414
export const childIsOfComponentType = (
15-
child:
16-
| string
17-
| number
18-
| boolean
19-
| ReactElement<any, string | JSXElementConstructor<any>>
20-
| Iterable<ReactNode>
21-
| ReactPortal
22-
| null
23-
| undefined,
15+
child: Exclude<ReactNode, boolean | null | undefined>,
2416
component: FC,
2517
): child is ReactElement<any, string | JSXElementConstructor<any>> | ReactPortal =>
2618
child !== undefined &&

0 commit comments

Comments
 (0)