Skip to content

Commit 9224b63

Browse files
committed
types
1 parent 4effd46 commit 9224b63

File tree

8 files changed

+15
-29
lines changed

8 files changed

+15
-29
lines changed

packages/react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"@types/history-5": "npm:@types/history@4.7.8",
5959
"@types/hoist-non-react-statics": "^3.3.5",
6060
"@types/node-fetch": "^2.6.0",
61-
"@types/react": "^18.0.0",
61+
"@types/react": "17.0.3",
6262
"@types/react-router-3": "npm:@types/react-router@3.0.24",
6363
"@types/react-router-4": "npm:@types/react-router@5.1.14",
6464
"@types/react-router-5": "npm:@types/react-router@5.1.14",

packages/react/src/errorboundary.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,7 @@ function withErrorBoundary<P extends Record<string, any>>(
201201

202202
// Copy over static methods from Wrapped component to Profiler HOC
203203
// See: https://reactjs.org/docs/higher-order-components.html#static-methods-must-be-copied-over
204-
// Need to set type to any because of hoist-non-react-statics typing
205-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
206-
hoistNonReactStatics(Wrapped, WrappedComponent as any);
204+
hoistNonReactStatics(Wrapped, WrappedComponent);
207205
return Wrapped;
208206
}
209207

packages/react/src/profiler.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,7 @@ function withProfiler<P extends Record<string, any>>(
169169

170170
// Copy over static methods from Wrapped component to Profiler HOC
171171
// See: https://reactjs.org/docs/higher-order-components.html#static-methods-must-be-copied-over
172-
// Need to set type to any because of hoist-non-react-statics typing
173-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
174-
hoistNonReactStatics(Wrapped, WrappedComponent as any);
172+
hoistNonReactStatics(Wrapped, WrappedComponent);
175173
return Wrapped;
176174
}
177175

packages/react/src/reactrouter.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export type RouteConfig = {
3232
[propName: string]: unknown;
3333
path?: string | string[];
3434
exact?: boolean;
35-
component?: React.JSX.Element;
35+
component?: JSX.Element;
3636
routes?: RouteConfig[];
3737
};
3838

@@ -244,8 +244,7 @@ export function withSentryRouting<P extends Record<string, any>, R extends React
244244
};
245245

246246
WrappedRoute.displayName = `sentryRoute(${componentDisplayName})`;
247-
// Need to set type to any because of hoist-non-react-statics typing
248-
hoistNonReactStatics(WrappedRoute, Route as any);
247+
hoistNonReactStatics(WrappedRoute, Route);
249248
// @ts-expect-error Setting more specific React Component typing for `R` generic above
250249
// will break advanced type inference done by react router params:
251250
// https://github.com/DefinitelyTyped/DefinitelyTyped/blob/13dc4235c069e25fe7ee16e11f529d909f9f3ff8/types/react-router/index.d.ts#L154-L164

packages/react/src/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Disabling `no-explicit-any` for the whole file as `any` has became common requirement.
22
/* eslint-disable @typescript-eslint/no-explicit-any */
3-
import type { JSX } from 'react';
43

54
export type Action = 'PUSH' | 'REPLACE' | 'POP';
65

packages/react/test/errorboundary.test.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ jest.mock('@sentry/browser', () => {
2626
};
2727
});
2828

29-
function Boo({ title }: { title: string }): React.JSX.Element {
29+
function Boo({ title }: { title: string }): JSX.Element {
3030
throw new Error(title);
3131
}
3232

33-
function Bam(): React.JSX.Element {
33+
function Bam(): JSX.Element {
3434
const [title] = useState('boom');
3535
return <Boo title={title} />;
3636
}
3737

38-
function EffectSpyFallback({ error }: { error: unknown }): React.JSX.Element {
38+
function EffectSpyFallback({ error }: { error: unknown }): JSX.Element {
3939
const [counter, setCounter] = useState(0);
4040

4141
React.useEffect(() => {
@@ -50,10 +50,10 @@ function EffectSpyFallback({ error }: { error: unknown }): React.JSX.Element {
5050
}
5151

5252
interface TestAppProps extends ErrorBoundaryProps {
53-
errorComp?: React.JSX.Element;
53+
errorComp?: JSX.Element;
5454
}
5555

56-
const TestApp: React.FC<TestAppProps> = ({ children, errorComp, ...props }) => {
56+
const TestApp: React.FC<TestAppProps> = ({ children, errorComp, ...props }): any => {
5757
const customErrorComp = errorComp || <Bam />;
5858
const [isError, setError] = React.useState(false);
5959
return (
@@ -282,7 +282,7 @@ describe('ErrorBoundary', () => {
282282
it('does not set cause if non Error objected is thrown', () => {
283283
const TestAppThrowingString: React.FC<ErrorBoundaryProps> = ({ children, ...props }) => {
284284
const [isError, setError] = React.useState(false);
285-
function StringBam(): React.JSX.Element {
285+
function StringBam(): JSX.Element {
286286
throw 'bam';
287287
}
288288
return (
@@ -333,7 +333,7 @@ describe('ErrorBoundary', () => {
333333
it('handles when `error.cause` is nested', () => {
334334
const mockOnError = jest.fn();
335335

336-
function CustomBam(): React.JSX.Element {
336+
function CustomBam(): JSX.Element {
337337
const firstError = new Error('bam');
338338
const secondError = new Error('bam2');
339339
const thirdError = new Error('bam3');
@@ -378,7 +378,7 @@ describe('ErrorBoundary', () => {
378378
it('handles when `error.cause` is recursive', () => {
379379
const mockOnError = jest.fn();
380380

381-
function CustomBam(): React.JSX.Element {
381+
function CustomBam(): JSX.Element {
382382
const firstError = new Error('bam');
383383
const secondError = new Error('bam2');
384384
// @ts-expect-error Need to set cause on error

packages/react/test/reactrouterv3.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jest.mock('@sentry/core', () => {
6262

6363
describe('browserTracingReactRouterV3', () => {
6464
const routes = (
65-
<Route path="/" component={({ children }: { children: React.JSX.Element }) => <div>{children}</div>}>
65+
<Route path="/" component={({ children }: { children: JSX.Element }) => <div>{children}</div>}>
6666
<IndexRoute component={() => <div>Home</div>} />
6767
<Route path="about" component={() => <div>About</div>} />
6868
<Route path="features" component={() => <div>Features</div>} />

yarn.lock

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8833,7 +8833,7 @@
88338833
dependencies:
88348834
"@types/react" "*"
88358835

8836-
"@types/react@*", "@types/react@>=16.9.0":
8836+
"@types/react@*", "@types/react@17.0.3", "@types/react@>=16.9.0":
88378837
version "17.0.3"
88388838
resolved "https://registry.yarnpkg.com/@types/react/-/react-17.0.3.tgz#ba6e215368501ac3826951eef2904574c262cc79"
88398839
integrity sha512-wYOUxIgs2HZZ0ACNiIayItyluADNbONl7kt8lkLjVK8IitMH5QMyAh75Fwhmo37r1m7L2JaFj03sIfxBVDvRAg==
@@ -8842,14 +8842,6 @@
88428842
"@types/scheduler" "*"
88438843
csstype "^3.0.2"
88448844

8845-
"@types/react@^18.0.0":
8846-
version "18.3.3"
8847-
resolved "https://registry.yarnpkg.com/@types/react/-/react-18.3.3.tgz#9679020895318b0915d7a3ab004d92d33375c45f"
8848-
integrity sha512-hti/R0pS0q1/xx+TsI73XIqk26eBsISZ2R0wUijXIngRK9R/e7Xw/cXVxQK7R5JjW+SV4zGcn5hXjudkN/pLIw==
8849-
dependencies:
8850-
"@types/prop-types" "*"
8851-
csstype "^3.0.2"
8852-
88538845
"@types/resolve@1.17.1":
88548846
version "1.17.1"
88558847
resolved "https://registry.yarnpkg.com/@types/resolve/-/resolve-1.17.1.tgz#3afd6ad8967c77e4376c598a82ddd58f46ec45d6"

0 commit comments

Comments
 (0)