Skip to content

Commit 64c45e7

Browse files
committed
ts3.8 fixes
1 parent 8753cac commit 64c45e7

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

packages/core/src/integrations/express/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,8 @@ export function expressErrorHandler(options?: ExpressHandlerOptions): ExpressErr
244244
*/
245245
export function setupExpressErrorHandler(
246246
app: {
247-
use: (middleware: ExpressMiddleware | ExpressErrorMiddleware) => unknown;
247+
//oxlint-disable-next-line no-explicit-any
248+
use: (middleware: any) => unknown;
248249
},
249250
options?: ExpressHandlerOptions,
250251
): void {

packages/core/src/integrations/express/types.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { RequestEventData } from '../../types-hoist/request';
22
import type { SpanAttributes } from '../../types-hoist/span';
33

4+
export const kLayerPatched: unique symbol = Symbol('express-layer-patched');
45
export const ATTR_EXPRESS_NAME = 'express.name';
56
export const ATTR_HTTP_ROUTE = 'http.route';
67
export const ATTR_EXPRESS_TYPE = 'express.type';
@@ -23,8 +24,9 @@ export type ExpressModuleExport = ExpressExport | { default: ExpressExport };
2324
export interface ExpressRequest extends RequestEventData {
2425
originalUrl: string;
2526
route: unknown;
26-
application: ExpressApplication;
27-
res: ExpressResponse;
27+
// Note: req.res is typed as optional (only present after middleware init).
28+
// mark optional to preserve compat with express v4 types.
29+
res?: ExpressResponse;
2830
}
2931

3032
// just a minimum type def for what we need, since this also needs to
@@ -101,8 +103,6 @@ export type ExpressRouter = {
101103
use(...handlers: unknown[]): unknown;
102104
};
103105

104-
export const kLayerPatched: unique symbol = Symbol('express-layer-patched');
105-
106106
export type IgnoreMatcher = string | RegExp | ((name: string) => boolean);
107107

108108
export type ExpressIntegrationOptions = {

packages/core/src/integrations/express/utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export const satisfiesPattern = (constant: string, pattern: IgnoreMatcher): bool
5050
* @param error - User-provided error value
5151
* @returns Both an Error or string representation of the value and an error message
5252
*/
53-
export const asErrorAndMessage = (error: unknown): [error: string | Error, message: string] =>
53+
export const asErrorAndMessage = (error: unknown): [string | Error, string] =>
5454
error instanceof Error ? [error, error.message] : [String(error), String(error)];
5555

5656
/**
@@ -118,7 +118,7 @@ export const getRouterPath = (path: string, layer: ExpressLayer): string => {
118118
return `${path}${stackLayer.route.path}`;
119119
}
120120

121-
if (Array.isArray(stackLayer?.handle?.stack)) {
121+
if (stackLayer && Array.isArray(stackLayer?.handle?.stack)) {
122122
return getRouterPath(path, stackLayer);
123123
}
124124

@@ -142,7 +142,7 @@ export const isLayerIgnored = (
142142
if (Array.isArray(config?.ignoreLayersType) && config?.ignoreLayersType?.includes(type)) {
143143
return true;
144144
}
145-
if (Array.isArray(config?.ignoreLayers) === false) return false;
145+
if (!Array.isArray(config?.ignoreLayers)) return false;
146146
try {
147147
for (const pattern of config.ignoreLayers) {
148148
if (satisfiesPattern(name, pattern)) {

packages/node/src/integrations/tracing/express.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ const INTEGRATION_NAME = 'Express';
2525
const SUPPORTED_VERSIONS = ['>=4.0.0 <6'];
2626

2727
export function setupExpressErrorHandler(
28-
app: { use: (middleware: ExpressMiddleware | ExpressErrorMiddleware) => unknown },
28+
//oxlint-disable-next-line no-explicit-any
29+
app: { use: (middleware: any) => unknown },
2930
options?: ExpressHandlerOptions,
3031
): void {
3132
coreSetupExpressErrorHandler(app, options);

0 commit comments

Comments
 (0)