Skip to content

Commit

Permalink
ref(build): Turn on isolatedModules TS option (#4497)
Browse files Browse the repository at this point in the history
  • Loading branch information
lobsterkatie committed Apr 7, 2022
1 parent 7c3e9d0 commit 03ce51a
Show file tree
Hide file tree
Showing 29 changed files with 127 additions and 125 deletions.
4 changes: 3 additions & 1 deletion packages/angular/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
export type { ErrorHandlerOptions } from './errorhandler';

export * from '@sentry/browser';

export { init } from './sdk';
export { createErrorHandler, ErrorHandlerOptions, SentryErrorHandler } from './errorhandler';
export { createErrorHandler, SentryErrorHandler } from './errorhandler';
export {
getActiveTransaction,
// TODO `instrumentAngularRouting` is just an alias for `routingInstrumentation`; deprecate the latter at some point
Expand Down
2 changes: 1 addition & 1 deletion packages/browser/src/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class BrowserBackend extends BaseBackend<BrowserOptions> {
/**
* @inheritDoc
*/
public eventFromMessage(message: string, level: Severity = Severity.Info, hint?: EventHint): PromiseLike<Event> {
public eventFromMessage(message: string, level: Severity = 'info' as Severity, hint?: EventHint): PromiseLike<Event> {
return eventFromMessage(message, level, hint, this._options.attachStacktrace);
}

Expand Down
4 changes: 2 additions & 2 deletions packages/browser/src/eventbuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export function eventFromException(
const syntheticException = (hint && hint.syntheticException) || undefined;
const event = eventFromUnknownInput(exception, syntheticException, attachStacktrace);
addExceptionMechanism(event); // defaults to { type: 'generic', handled: true }
event.level = Severity.Error;
event.level = 'error' as Severity;
if (hint && hint.event_id) {
event.event_id = hint.event_id;
}
Expand All @@ -174,7 +174,7 @@ export function eventFromException(
*/
export function eventFromMessage(
message: string,
level: Severity = Severity.Info,
level: Severity = 'info' as Severity,
hint?: EventHint,
attachStacktrace?: boolean,
): PromiseLike<Event> {
Expand Down
10 changes: 6 additions & 4 deletions packages/browser/src/exports.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export {
export type {
Breadcrumb,
BreadcrumbHint,
Request,
Expand All @@ -15,7 +15,10 @@ export {
User,
} from '@sentry/types';

export { SeverityLevel } from '@sentry/utils';
export type { SeverityLevel } from '@sentry/utils';

export type { BrowserOptions } from './backend';
export type { ReportDialogOptions } from './helpers';

export {
addGlobalEventProcessor,
Expand All @@ -41,8 +44,7 @@ export {
withScope,
} from '@sentry/core';

export { BrowserOptions } from './backend';
export { BrowserClient } from './client';
export { injectReportDialog, ReportDialogOptions } from './helpers';
export { injectReportDialog } from './helpers';
export { defaultIntegrations, forceLoad, init, lastEventId, onLoad, showReportDialog, flush, close, wrap } from './sdk';
export { SDK_NAME } from './version';
2 changes: 1 addition & 1 deletion packages/browser/src/integrations/breadcrumbs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ function _fetchBreadcrumb(handlerData: { [key: string]: any }): void {
{
category: 'fetch',
data: handlerData.fetchData,
level: Severity.Error,
level: 'error' as Severity,
type: 'http',
},
{
Expand Down
4 changes: 2 additions & 2 deletions packages/browser/src/integrations/globalhandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function _installGlobalOnErrorHandler(): void {
column,
);

event.level = Severity.Error;
event.level = 'error' as Severity;

addMechanismAndCapture(hub, error, event, 'onerror');
},
Expand Down Expand Up @@ -144,7 +144,7 @@ function _installGlobalOnUnhandledRejectionHandler(): void {
? _eventFromRejectionWithPrimitive(error)
: eventFromUnknownInput(error, undefined, attachStacktrace, true);

event.level = Severity.Error;
event.level = 'error' as Severity;

addMechanismAndCapture(hub, error, event, 'onunhandledrejection');
return;
Expand Down
26 changes: 15 additions & 11 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
export type { APIDetails } from './api';
export type { BackendClass } from './basebackend';
export type { ClientClass } from './sdk';
export type {
BaseTransportOptions,
NewTransport,
TransportMakeRequestResponse,
TransportRequest,
TransportRequestExecutor,
} from './transports/base';

export {
addBreadcrumb,
captureException,
Expand All @@ -15,26 +26,19 @@ export {
} from '@sentry/minimal';
export { addGlobalEventProcessor, getCurrentHub, getHubFromCarrier, Hub, makeMain, Scope, Session } from '@sentry/hub';
export {
APIDetails,
getEnvelopeEndpointWithUrlEncodedAuth,
getStoreEndpointWithUrlEncodedAuth,
getRequestHeaders,
initAPIDetails,
getReportDialogEndpoint,
} from './api';
export { BaseClient } from './baseclient';
export { BackendClass, BaseBackend } from './basebackend';
export { BaseBackend } from './basebackend';
export { eventToSentryRequest, sessionToSentryRequest } from './request';
export { initAndBind, ClientClass } from './sdk';
export { initAndBind } from './sdk';
export { NoopTransport } from './transports/noop';
export {
BaseTransportOptions,
createTransport,
NewTransport,
TransportMakeRequestResponse,
TransportRequest,
TransportRequestExecutor,
} from './transports/base';
export { createTransport } from './transports/base';

export { SDK_VERSION } from './version';

import * as Integrations from './integrations';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/mocks/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class TestBackend extends BaseBackend<TestOptions> {
});
}

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

Expand Down
13 changes: 3 additions & 10 deletions packages/hub/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
export type { Carrier, Layer } from './hub';

export { addGlobalEventProcessor, Scope } from './scope';
export { Session } from './session';
export { SessionFlusher } from './sessionflusher';
export {
getCurrentHub,
getHubFromCarrier,
getMainCarrier,
Hub,
makeMain,
setHubOnCarrier,
Carrier,
Layer,
} from './hub';
export { getCurrentHub, getHubFromCarrier, getMainCarrier, Hub, makeMain, setHubOnCarrier } from './hub';
20 changes: 10 additions & 10 deletions packages/hub/test/scope.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ describe('Scope', () => {

test('setLevel', () => {
const scope = new Scope();
scope.setLevel(Severity.Critical);
expect((scope as any)._level).toEqual(Severity.Critical);
scope.setLevel('critical' as Severity);
expect((scope as any)._level).toEqual('critical' as Severity);
});

test('setTransactionName', () => {
Expand Down Expand Up @@ -137,8 +137,8 @@ describe('Scope', () => {

test('chaining', () => {
const scope = new Scope();
scope.setLevel(Severity.Critical).setUser({ id: '1' });
expect((scope as any)._level).toEqual(Severity.Critical);
scope.setLevel('critical' as Severity).setUser({ id: '1' });
expect((scope as any)._level).toEqual('critical' as Severity);
expect((scope as any)._user).toEqual({ id: '1' });
});
});
Expand Down Expand Up @@ -202,7 +202,7 @@ describe('Scope', () => {
scope.setTag('a', 'b');
scope.setUser({ id: '1' });
scope.setFingerprint(['abcd']);
scope.setLevel(Severity.Warning);
scope.setLevel('warning' as Severity);
scope.setTransactionName('/abc');
scope.addBreadcrumb({ message: 'test' });
scope.setContext('os', { id: '1' });
Expand Down Expand Up @@ -294,11 +294,11 @@ describe('Scope', () => {
test('scope level should have priority over event level', () => {
expect.assertions(1);
const scope = new Scope();
scope.setLevel(Severity.Warning);
scope.setLevel('warning' as Severity);
const event: Event = {};
event.level = Severity.Critical;
event.level = 'critical' as Severity;
return scope.applyToEvent(event).then(processedEvent => {
expect(processedEvent!.level).toEqual(Severity.Warning);
expect(processedEvent!.level).toEqual('warning' as Severity);
});
});

Expand Down Expand Up @@ -410,7 +410,7 @@ describe('Scope', () => {
scope.setContext('foo', { id: '1' });
scope.setContext('bar', { id: '2' });
scope.setUser({ id: '1337' });
scope.setLevel(Severity.Info);
scope.setLevel('info' as Severity);
scope.setFingerprint(['foo']);
scope.setRequestSession({ status: 'ok' });
});
Expand Down Expand Up @@ -458,7 +458,7 @@ describe('Scope', () => {
localScope.setContext('bar', { id: '3' });
localScope.setContext('baz', { id: '4' });
localScope.setUser({ id: '42' });
localScope.setLevel(Severity.Warning);
localScope.setLevel('warning' as Severity);
localScope.setFingerprint(['bar']);
(localScope as any)._requestSession = { status: 'ok' };

Expand Down
12 changes: 6 additions & 6 deletions packages/minimal/test/lib/minimal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ describe('Minimal', () => {
const client: any = new TestClient({});
const scope = getCurrentHub().pushScope();
getCurrentHub().bindClient(client);
scope.setLevel(Severity.Warning);
expect(global.__SENTRY__.hub._stack[1].scope._level).toEqual(Severity.Warning);
scope.setLevel('warning' as Severity);
expect(global.__SENTRY__.hub._stack[1].scope._level).toEqual('warning' as Severity);
});
});

Expand Down Expand Up @@ -245,16 +245,16 @@ describe('Minimal', () => {

test('withScope', () => {
withScope(scope => {
scope.setLevel(Severity.Warning);
scope.setLevel('warning' as Severity);
scope.setFingerprint(['1']);
withScope(scope2 => {
scope2.setLevel(Severity.Info);
scope2.setLevel('info' as Severity);
scope2.setFingerprint(['2']);
withScope(scope3 => {
scope3.clear();
expect(global.__SENTRY__.hub._stack[1].scope._level).toEqual(Severity.Warning);
expect(global.__SENTRY__.hub._stack[1].scope._level).toEqual('warning' as Severity);
expect(global.__SENTRY__.hub._stack[1].scope._fingerprint).toEqual(['1']);
expect(global.__SENTRY__.hub._stack[2].scope._level).toEqual(Severity.Info);
expect(global.__SENTRY__.hub._stack[2].scope._level).toEqual('info' as Severity);
expect(global.__SENTRY__.hub._stack[2].scope._fingerprint).toEqual(['2']);
expect(global.__SENTRY__.hub._stack[3].scope._level).toBeUndefined();
});
Expand Down
2 changes: 1 addition & 1 deletion packages/nextjs/src/index.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ function filterTransactions(event: Event): Event | null {
return event.type === 'transaction' && event.transaction === '/404' ? null : event;
}

export type { SentryWebpackPluginOptions } from './config/types';
export { withSentryConfig } from './config';
export { SentryWebpackPluginOptions } from './config/types';
export { withSentry } from './utils/withSentry';

// Wrap various server methods to enable error monitoring and tracing. (Note: This only happens for non-Vercel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Sentry.init({
Sentry.addBreadcrumb({
category: 'foo',
message: 'bar',
level: Sentry.Severity.Critical,
level: 'critical' as Sentry.Severity,
});

Sentry.addBreadcrumb({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Sentry.init({
Sentry.addBreadcrumb({
category: 'foo',
message: 'bar',
level: Sentry.Severity.Critical,
level: 'critical' as Sentry.Severity,
});

Sentry.captureMessage('test_simple');
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Sentry.init({
release: '1.0',
});

Sentry.captureMessage('debug_message', Sentry.Severity.Debug);
Sentry.captureMessage('info_message', Sentry.Severity.Info);
Sentry.captureMessage('warning_message', Sentry.Severity.Warning);
Sentry.captureMessage('error_message', Sentry.Severity.Error);
Sentry.captureMessage('fatal_message', Sentry.Severity.Fatal);
Sentry.captureMessage('critical_message', Sentry.Severity.Critical);
Sentry.captureMessage('log_message', Sentry.Severity.Log);
Sentry.captureMessage('debug_message', 'debug' as Sentry.Severity);
Sentry.captureMessage('info_message', 'info' as Sentry.Severity);
Sentry.captureMessage('warning_message', 'warning' as Sentry.Severity);
Sentry.captureMessage('error_message', 'error' as Sentry.Severity);
Sentry.captureMessage('fatal_message', 'fatal' as Sentry.Severity);
Sentry.captureMessage('critical_message', 'critical' as Sentry.Severity);
Sentry.captureMessage('log_message', 'log' as Sentry.Severity);
2 changes: 1 addition & 1 deletion packages/node/src/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class NodeBackend extends BaseBackend<NodeOptions> {
/**
* @inheritDoc
*/
public eventFromMessage(message: string, level: Severity = Severity.Info, hint?: EventHint): PromiseLike<Event> {
public eventFromMessage(message: string, level: Severity = 'info' as Severity, hint?: EventHint): PromiseLike<Event> {
return resolvedSyncPromise(eventFromMessage(message, level, hint, this._options.attachStacktrace));
}

Expand Down
2 changes: 1 addition & 1 deletion packages/node/src/eventbuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export function eventFromUnknownInput(exception: unknown, hint?: EventHint): Eve
*/
export function eventFromMessage(
message: string,
level: Severity = Severity.Info,
level: Severity = 'info' as Severity,
hint?: EventHint,
attachStacktrace?: boolean,
): Event {
Expand Down
7 changes: 4 additions & 3 deletions packages/node/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export {
export type {
Breadcrumb,
BreadcrumbHint,
Request,
Expand All @@ -15,7 +15,9 @@ export {
User,
} from '@sentry/types';

export { SeverityLevel } from '@sentry/utils';
export type { SeverityLevel } from '@sentry/utils';

export type { NodeOptions } from './types';

export {
addGlobalEventProcessor,
Expand All @@ -41,7 +43,6 @@ export {
withScope,
} from '@sentry/core';

export { NodeOptions } from './types';
export { NodeBackend } from './backend';
export { NodeClient } from './client';
export { defaultIntegrations, init, lastEventId, flush, close, getSentryRelease } from './sdk';
Expand Down
2 changes: 1 addition & 1 deletion packages/node/src/integrations/onuncaughtexception.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class OnUncaughtException implements Integration {

if (hub.getIntegration(OnUncaughtException)) {
hub.withScope((scope: Scope) => {
scope.setLevel(Severity.Fatal);
scope.setLevel('fatal' as Severity);
hub.captureException(error, {
originalException: error,
data: { mechanism: { handled: false, type: 'onuncaughtexception' } },
Expand Down
3 changes: 2 additions & 1 deletion packages/node/src/transports/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export type { NodeTransportOptions } from './new';
export { BaseTransport } from './base';
export { HTTPTransport } from './http';
export { HTTPSTransport } from './https';
export { makeNodeTransport, NodeTransportOptions } from './new';
export { makeNodeTransport } from './new';
2 changes: 1 addition & 1 deletion packages/serverless/src/awslambda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ export function wrapHandler<TEvent, TResult>(
timeoutWarningTimer = setTimeout(() => {
withScope(scope => {
scope.setTag('timeout', humanReadableTimeout);
captureMessage(`Possible function timeout: ${context.functionName}`, Sentry.Severity.Warning);
captureMessage(`Possible function timeout: ${context.functionName}`, 'warning' as Sentry.Severity);
});
}, timeoutWarningDelay);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/serverless/src/gcpfunction/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@ export function configureScopeWithContext(scope: Scope, context: Context): void
scope.setContext('gcp.function.context', { ...context } as SentryContext);
}

export { Request, Response };
export type { Request, Response };
8 changes: 3 additions & 5 deletions packages/tracing/src/browser/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
export type { RequestInstrumentationOptions } from './request';

export { BrowserTracing } from './browsertracing';
export {
instrumentOutgoingRequests,
RequestInstrumentationOptions,
defaultRequestInstrumentationOptions,
} from './request';
export { instrumentOutgoingRequests, defaultRequestInstrumentationOptions } from './request';
Loading

0 comments on commit 03ce51a

Please sign in to comment.