Skip to content

Commit cefc1b1

Browse files
ref(ts): Prefer component return types to be inferred (#7355)
JSX.Element isn't always quite the right return type for components. We can simplify this and just let typescript infer the return type for components (which is inline with what we do in sentry)
1 parent 5c4771c commit cefc1b1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+46
-59
lines changed

src/components/alert.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,7 @@ type Props = {
88
title?: string;
99
};
1010

11-
export function Alert({
12-
title,
13-
children,
14-
level,
15-
deepLink,
16-
dismiss = false,
17-
}: Props): JSX.Element {
11+
export function Alert({title, children, level, deepLink, dismiss = false}: Props) {
1812
let className = 'alert';
1913
if (level) {
2014
className += ` alert-${level}`;

src/components/basePage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export function BasePage({
5656
sidebar,
5757
children,
5858
prependToc,
59-
}: Props): JSX.Element {
59+
}: Props) {
6060
const tx = getCurrentTransaction();
6161
if (tx) {
6262
tx.setStatus('ok');

src/components/cliChecksumTable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const ChecksumValue = styled.code`
2222
white-space: nowrap;
2323
`;
2424

25-
export function CliChecksumTable(): JSX.Element {
25+
export function CliChecksumTable() {
2626
const {
2727
app: {files, version},
2828
} = useStaticQuery(query);

src/components/codeBlock.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ const ItemButton = styled('button')<{isActive: boolean}>`
317317
`}
318318
`;
319319

320-
function CodeWrapper(props): JSX.Element {
320+
function CodeWrapper(props) {
321321
const {children, class: className, ...rest} = props;
322322

323323
return (
@@ -327,7 +327,7 @@ function CodeWrapper(props): JSX.Element {
327327
);
328328
}
329329

330-
function SpanWrapper(props): JSX.Element {
330+
function SpanWrapper(props) {
331331
const {children, class: className, ...rest} = props;
332332
return (
333333
<span className={className} {...rest}>
@@ -343,7 +343,7 @@ type Props = {
343343
title?: string;
344344
};
345345

346-
export function CodeBlock({filename, language, children}: Props): JSX.Element {
346+
export function CodeBlock({filename, language, children}: Props) {
347347
const [showCopied, setShowCopied] = useState(false);
348348
const codeRef = useRef(null);
349349

src/components/codeTabs.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ type Props = {
2424
children: JSX.Element | JSX.Element[];
2525
};
2626

27-
export function CodeTabs({children}: Props): JSX.Element {
27+
export function CodeTabs({children}: Props) {
2828
if (!Array.isArray(children)) {
2929
children = [children];
3030
} else {

src/components/configKey.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export function ConfigKey({
1717
notSupported = [],
1818
children,
1919
platform,
20-
}: Props): JSX.Element {
20+
}: Props) {
2121
// This is a literal copypaste of the HTML Gatsby outputs for regular
2222
// Markdown headings because we can't figure out how to make Gatsby
2323
// render component content like regular markdown/MDX content. We tried

src/components/content.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function RawHtml({html}) {
2020
return <div dangerouslySetInnerHTML={{__html: html}} />;
2121
}
2222

23-
export function Content({file}: Props): JSX.Element | null {
23+
export function Content({file}: Props) {
2424
if (!file) {
2525
return null;
2626
}

src/components/definitionList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
22

3-
export function DefinitionList({children}: {children: React.ReactNode}): JSX.Element {
3+
export function DefinitionList({children}: {children: React.ReactNode}) {
44
return <div className="large-definition-list">{children}</div>;
55
}

src/components/dynamicNav.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,7 @@ type ChildrenProps = {
8484
showDepth?: number;
8585
};
8686

87-
export function Children({
88-
tree,
89-
exclude = [],
90-
showDepth = 0,
91-
}: ChildrenProps): JSX.Element {
87+
export function Children({tree, exclude = [], showDepth = 0}: ChildrenProps) {
9288
return <React.Fragment>{renderChildren(tree, exclude, showDepth)}</React.Fragment>;
9389
}
9490

@@ -114,7 +110,7 @@ export function DynamicNav({
114110
prependLinks = [],
115111
suppressMissing = false,
116112
noHeadingLink = false,
117-
}: Props): JSX.Element | null {
113+
}: Props) {
118114
const location = useLocation();
119115

120116
if (root.startsWith('/')) {

src/components/expandable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const ExpandableBody = styled.div<ExpandedProps>`
2222
display: ${props => (props.isExpanded ? 'block' : 'none')};
2323
`;
2424

25-
export function Expandable({title, children}: Props): JSX.Element {
25+
export function Expandable({title, children}: Props) {
2626
const [isExpanded, setIsExpanded] = useState(false);
2727
return (
2828
<div className="note">

0 commit comments

Comments
 (0)