Skip to content

Commit 225d1fa

Browse files
committed
fix types
1 parent 62a24c0 commit 225d1fa

File tree

5 files changed

+16
-8
lines changed

5 files changed

+16
-8
lines changed

packages/browser/src/integrations/breadcrumbs.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ function _consoleBreadcrumb(handlerData: HandlerData & { args: unknown[]; level:
216216
/**
217217
* Creates breadcrumbs from XHR API calls
218218
*/
219-
function _xhrBreadcrumb(handlerData: HandlerData & { xhr: SentryWrappedXMLHttpRequest }): void {
219+
function _xhrBreadcrumb(handlerData: HandlerData & { xhr: XMLHttpRequest & SentryWrappedXMLHttpRequest }): void {
220220
if (handlerData.endTimestamp) {
221221
// We only capture complete, non-sentry requests
222222
if (handlerData.xhr.__sentry_own_request__) {
@@ -248,7 +248,7 @@ function _xhrBreadcrumb(handlerData: HandlerData & { xhr: SentryWrappedXMLHttpRe
248248
/**
249249
* Creates breadcrumbs from fetch API calls
250250
*/
251-
function _fetchBreadcrumb(handlerData: HandlerData & HandlerDataFetch): void {
251+
function _fetchBreadcrumb(handlerData: HandlerData & HandlerDataFetch & { response?: Response }): void {
252252
// We only capture complete fetch requests
253253
if (!handlerData.endTimestamp) {
254254
return;

packages/types/.eslintrc.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
module.exports = {
22
extends: ['../../.eslintrc.js'],
3+
env: {
4+
node: true,
5+
browser: false,
6+
},
37
rules: {
48
'@typescript-eslint/no-explicit-any': 'off',
59
},

packages/types/src/instrument.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
type XHRSendInput = null | Blob | BufferSource | FormData | URLSearchParams | string;
1+
// This should be: null | Blob | BufferSource | FormData | URLSearchParams | string
2+
// But since not all of those are available in node, we just export `unknown` here for now
3+
// Make sure to cast it where needed!
4+
type XHRSendInput = unknown;
25

3-
export interface SentryWrappedXMLHttpRequest extends XMLHttpRequest {
6+
export interface SentryWrappedXMLHttpRequest {
47
[key: string]: any;
58
__sentry_xhr__?: {
69
method?: string;
@@ -19,5 +22,6 @@ export interface HandlerDataFetch {
1922
args: any[];
2023
fetchData: SentryFetchData;
2124
startTimestamp: number;
22-
response?: Response;
25+
// This is actually `Response`, make sure to cast this where needed (not available in Node)
26+
response?: unknown;
2327
}

packages/types/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
"include": ["src/**/*"],
55

66
"compilerOptions": {
7-
// package-specific options
7+
"lib": ["ES6"]
88
}
99
}

packages/utils/src/instrument.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ function instrumentXHR(): void {
208208
const xhrproto = XMLHttpRequest.prototype;
209209

210210
fill(xhrproto, 'open', function (originalOpen: () => void): () => void {
211-
return function (this: SentryWrappedXMLHttpRequest, ...args: any[]): void {
211+
return function (this: XMLHttpRequest & SentryWrappedXMLHttpRequest, ...args: any[]): void {
212212
// eslint-disable-next-line @typescript-eslint/no-this-alias
213213
const xhr = this;
214214
const url = args[1];
@@ -259,7 +259,7 @@ function instrumentXHR(): void {
259259
});
260260

261261
fill(xhrproto, 'send', function (originalSend: () => void): () => void {
262-
return function (this: SentryWrappedXMLHttpRequest, ...args: any[]): void {
262+
return function (this: XMLHttpRequest & SentryWrappedXMLHttpRequest, ...args: any[]): void {
263263
if (this.__sentry_xhr__ && args[0] !== undefined) {
264264
this.__sentry_xhr__.body = args[0];
265265
}

0 commit comments

Comments
 (0)