Skip to content

Commit 1b28c23

Browse files
authored
feat(apm|tracing): Remove express typing (#2803)
1 parent b15824c commit 1b28c23

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

packages/apm/src/integrations/express.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
11
import { Integration, Transaction } from '@sentry/types';
22
import { logger } from '@sentry/utils';
3-
// tslint:disable-next-line:no-implicit-dependencies
4-
import { Application, ErrorRequestHandler, NextFunction, Request, RequestHandler, Response } from 'express';
3+
4+
// tslint:disable: completed-docs
5+
// Have to manually set types because we are using package-alias
6+
interface Application {
7+
use(...args: any): any;
8+
}
9+
10+
type ErrorRequestHandler = (...args: any) => any;
11+
type RequestHandler = (...args: any) => any;
12+
type NextFunction = (...args: any) => any;
13+
14+
interface Response {
15+
once(name: string, callback: () => void): void;
16+
}
17+
// tslint:enable: completed-docs
518

619
/**
720
* Internal helper for `__sentry_transaction`
@@ -167,6 +180,7 @@ function wrapUseArgs(args: IArguments): unknown[] {
167180
* Patches original app.use to utilize our tracing functionality
168181
*/
169182
function instrumentMiddlewares(app: Application): Application {
183+
// tslint:disable-next-line: no-unbound-method
170184
const originalAppUse = app.use;
171185
app.use = function(): any {
172186
return originalAppUse.apply(this, wrapUseArgs(arguments));

packages/tracing/src/integrations/express.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
11
import { Integration, Transaction } from '@sentry/types';
22
import { logger } from '@sentry/utils';
3-
// tslint:disable-next-line:no-implicit-dependencies
4-
import { Application, ErrorRequestHandler, NextFunction, Request, RequestHandler, Response } from 'express';
3+
4+
// tslint:disable: completed-docs
5+
// Have to manually set types because we are using package-alias
6+
interface Application {
7+
use(...args: any): any;
8+
}
9+
10+
type ErrorRequestHandler = (...args: any) => any;
11+
type RequestHandler = (...args: any) => any;
12+
type NextFunction = (...args: any) => any;
13+
14+
interface Response {
15+
once(name: string, callback: () => void): void;
16+
}
17+
// tslint:enable: completed-docs
518

619
/**
720
* Internal helper for `__sentry_transaction`
@@ -167,6 +180,7 @@ function wrapUseArgs(args: IArguments): unknown[] {
167180
* Patches original app.use to utilize our tracing functionality
168181
*/
169182
function instrumentMiddlewares(app: Application): Application {
183+
// tslint:disable-next-line: no-unbound-method
170184
const originalAppUse = app.use;
171185
app.use = function(): any {
172186
return originalAppUse.apply(this, wrapUseArgs(arguments));

0 commit comments

Comments
 (0)