Skip to content

Commit 4e89e5c

Browse files
authored
ref(build): Turn on isolatedModules TS option (#4497)
1 parent ab2c8c6 commit 4e89e5c

File tree

24 files changed

+107
-94
lines changed

24 files changed

+107
-94
lines changed

packages/angular/src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
export type { ErrorHandlerOptions } from './errorhandler';
2+
13
export * from '@sentry/browser';
24

35
export { init } from './sdk';
4-
export { createErrorHandler, ErrorHandlerOptions, SentryErrorHandler } from './errorhandler';
6+
export { createErrorHandler, SentryErrorHandler } from './errorhandler';
57
export {
68
getActiveTransaction,
79
// TODO `instrumentAngularRouting` is just an alias for `routingInstrumentation`; deprecate the latter at some point

packages/browser/src/backend.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export class BrowserBackend extends BaseBackend<BrowserOptions> {
4545
/**
4646
* @inheritDoc
4747
*/
48-
public eventFromMessage(message: string, level: Severity = Severity.Info, hint?: EventHint): PromiseLike<Event> {
48+
public eventFromMessage(message: string, level: Severity = 'info' as Severity, hint?: EventHint): PromiseLike<Event> {
4949
return eventFromMessage(this._options, message, level, hint);
5050
}
5151

packages/browser/src/eventbuilder.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export function eventFromException(options: Options, exception: unknown, hint?:
2424
attachStacktrace: options.attachStacktrace,
2525
});
2626
addExceptionMechanism(event); // defaults to { type: 'generic', handled: true }
27-
event.level = Severity.Error;
27+
event.level = 'error' as Severity;
2828
if (hint && hint.event_id) {
2929
event.event_id = hint.event_id;
3030
}
@@ -38,7 +38,7 @@ export function eventFromException(options: Options, exception: unknown, hint?:
3838
export function eventFromMessage(
3939
options: Options,
4040
message: string,
41-
level: Severity = Severity.Info,
41+
level: Severity = 'info' as Severity,
4242
hint?: EventHint,
4343
): PromiseLike<Event> {
4444
const syntheticException = (hint && hint.syntheticException) || undefined;

packages/browser/src/exports.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export {
1+
export type {
22
Breadcrumb,
33
BreadcrumbHint,
44
Request,
@@ -15,7 +15,10 @@ export {
1515
User,
1616
} from '@sentry/types';
1717

18-
export { SeverityLevel } from '@sentry/utils';
18+
export type { SeverityLevel } from '@sentry/utils';
19+
20+
export type { BrowserOptions } from './backend';
21+
export type { ReportDialogOptions } from './helpers';
1922

2023
export {
2124
addGlobalEventProcessor,
@@ -40,9 +43,8 @@ export {
4043
withScope,
4144
} from '@sentry/core';
4245

43-
export { BrowserOptions } from './backend';
4446
export { BrowserClient } from './client';
45-
export { injectReportDialog, ReportDialogOptions } from './helpers';
47+
export { injectReportDialog } from './helpers';
4648
export { eventFromException, eventFromMessage } from './eventbuilder';
4749
export { defaultIntegrations, forceLoad, init, lastEventId, onLoad, showReportDialog, flush, close, wrap } from './sdk';
4850
export { SDK_NAME } from './version';

packages/browser/src/integrations/breadcrumbs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ function _fetchBreadcrumb(handlerData: { [key: string]: any }): void {
230230
{
231231
category: 'fetch',
232232
data: handlerData.fetchData,
233-
level: Severity.Error,
233+
level: 'error' as Severity,
234234
type: 'http',
235235
},
236236
{

packages/browser/src/integrations/globalhandlers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ function _installGlobalOnErrorHandler(): void {
101101
column,
102102
);
103103

104-
event.level = Severity.Error;
104+
event.level = 'error' as Severity;
105105

106106
addMechanismAndCapture(hub, error, event, 'onerror');
107107
},
@@ -150,7 +150,7 @@ function _installGlobalOnUnhandledRejectionHandler(): void {
150150
isRejection: true,
151151
});
152152

153-
event.level = Severity.Error;
153+
event.level = 'error' as Severity;
154154

155155
addMechanismAndCapture(hub, error, event, 'onunhandledrejection');
156156
return;

packages/core/src/index.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
export type { APIDetails } from './api';
2+
export type { BackendClass } from './basebackend';
3+
export type { ClientClass } from './sdk';
4+
15
export {
26
addBreadcrumb,
37
captureException,
@@ -17,17 +21,16 @@ export { addGlobalEventProcessor, getCurrentHub, getHubFromCarrier, Hub, makeMai
1721
export {
1822
// eslint-disable-next-line deprecation/deprecation
1923
API,
20-
APIDetails,
2124
getEnvelopeEndpointWithUrlEncodedAuth,
2225
getStoreEndpointWithUrlEncodedAuth,
2326
getRequestHeaders,
2427
initAPIDetails,
2528
getReportDialogEndpoint,
2629
} from './api';
2730
export { BaseClient } from './baseclient';
28-
export { BackendClass, BaseBackend } from './basebackend';
31+
export { BaseBackend } from './basebackend';
2932
export { eventToSentryRequest, sessionToSentryRequest } from './request';
30-
export { initAndBind, ClientClass } from './sdk';
33+
export { initAndBind } from './sdk';
3134
export { NoopTransport } from './transports/noop';
3235
export { SDK_VERSION } from './version';
3336

packages/core/test/mocks/backend.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class TestBackend extends BaseBackend<TestOptions> {
3838
});
3939
}
4040

41-
public eventFromMessage(message: string, level: Severity = Severity.Info): PromiseLike<Event> {
41+
public eventFromMessage(message: string, level: Severity = 'info' as Severity): PromiseLike<Event> {
4242
return resolvedSyncPromise({ message, level });
4343
}
4444

packages/hub/src/index.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
export type {
2+
Carrier,
3+
// eslint-disable-next-line deprecation/deprecation
4+
DomainAsCarrier,
5+
Layer,
6+
} from './hub';
7+
18
export { addGlobalEventProcessor, Scope } from './scope';
29
export { Session } from './session';
310
export { SessionFlusher } from './sessionflusher';
@@ -10,8 +17,4 @@ export {
1017
Hub,
1118
makeMain,
1219
setHubOnCarrier,
13-
Carrier,
14-
// eslint-disable-next-line deprecation/deprecation
15-
DomainAsCarrier,
16-
Layer,
1720
} from './hub';

packages/hub/test/scope.test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ describe('Scope', () => {
8585

8686
test('setLevel', () => {
8787
const scope = new Scope();
88-
scope.setLevel(Severity.Critical);
89-
expect((scope as any)._level).toEqual(Severity.Critical);
88+
scope.setLevel('critical' as Severity);
89+
expect((scope as any)._level).toEqual('critical' as Severity);
9090
});
9191

9292
test('setTransactionName', () => {
@@ -137,8 +137,8 @@ describe('Scope', () => {
137137

138138
test('chaining', () => {
139139
const scope = new Scope();
140-
scope.setLevel(Severity.Critical).setUser({ id: '1' });
141-
expect((scope as any)._level).toEqual(Severity.Critical);
140+
scope.setLevel('critical' as Severity).setUser({ id: '1' });
141+
expect((scope as any)._level).toEqual('critical' as Severity);
142142
expect((scope as any)._user).toEqual({ id: '1' });
143143
});
144144
});
@@ -202,7 +202,7 @@ describe('Scope', () => {
202202
scope.setTag('a', 'b');
203203
scope.setUser({ id: '1' });
204204
scope.setFingerprint(['abcd']);
205-
scope.setLevel(Severity.Warning);
205+
scope.setLevel('warning' as Severity);
206206
scope.setTransactionName('/abc');
207207
scope.addBreadcrumb({ message: 'test' });
208208
scope.setContext('os', { id: '1' });
@@ -294,11 +294,11 @@ describe('Scope', () => {
294294
test('scope level should have priority over event level', () => {
295295
expect.assertions(1);
296296
const scope = new Scope();
297-
scope.setLevel(Severity.Warning);
297+
scope.setLevel('warning' as Severity);
298298
const event: Event = {};
299-
event.level = Severity.Critical;
299+
event.level = 'critical' as Severity;
300300
return scope.applyToEvent(event).then(processedEvent => {
301-
expect(processedEvent!.level).toEqual(Severity.Warning);
301+
expect(processedEvent!.level).toEqual('warning' as Severity);
302302
});
303303
});
304304

@@ -410,7 +410,7 @@ describe('Scope', () => {
410410
scope.setContext('foo', { id: '1' });
411411
scope.setContext('bar', { id: '2' });
412412
scope.setUser({ id: '1337' });
413-
scope.setLevel(Severity.Info);
413+
scope.setLevel('info' as Severity);
414414
scope.setFingerprint(['foo']);
415415
scope.setRequestSession({ status: 'ok' });
416416
});
@@ -458,7 +458,7 @@ describe('Scope', () => {
458458
localScope.setContext('bar', { id: '3' });
459459
localScope.setContext('baz', { id: '4' });
460460
localScope.setUser({ id: '42' });
461-
localScope.setLevel(Severity.Warning);
461+
localScope.setLevel('warning' as Severity);
462462
localScope.setFingerprint(['bar']);
463463
(localScope as any)._requestSession = { status: 'ok' };
464464

0 commit comments

Comments
 (0)