Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref(build): Turn on isolatedModules TS option #4497

Merged
merged 3 commits into from
Feb 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -45,7 +45,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(this._options, message, level, hint);
}

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 @@ -24,7 +24,7 @@ export function eventFromException(options: Options, exception: unknown, hint?:
attachStacktrace: options.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 @@ -38,7 +38,7 @@ export function eventFromException(options: Options, exception: unknown, hint?:
export function eventFromMessage(
options: Options,
message: string,
level: Severity = Severity.Info,
level: Severity = 'info' as Severity,
hint?: EventHint,
): PromiseLike<Event> {
const syntheticException = (hint && hint.syntheticException) || undefined;
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 @@ -40,9 +43,8 @@ export {
withScope,
} from '@sentry/core';

export { BrowserOptions } from './backend';
export { BrowserClient } from './client';
export { injectReportDialog, ReportDialogOptions } from './helpers';
export { injectReportDialog } from './helpers';
export { eventFromException, eventFromMessage } from './eventbuilder';
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 @@ -101,7 +101,7 @@ function _installGlobalOnErrorHandler(): void {
column,
);

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

addMechanismAndCapture(hub, error, event, 'onerror');
},
Expand Down Expand Up @@ -150,7 +150,7 @@ function _installGlobalOnUnhandledRejectionHandler(): void {
isRejection: true,
});

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

addMechanismAndCapture(hub, error, event, 'onunhandledrejection');
return;
Expand Down
9 changes: 6 additions & 3 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
export type { APIDetails } from './api';
export type { BackendClass } from './basebackend';
export type { ClientClass } from './sdk';

export {
addBreadcrumb,
captureException,
Expand All @@ -17,17 +21,16 @@ export { addGlobalEventProcessor, getCurrentHub, getHubFromCarrier, Hub, makeMai
export {
// eslint-disable-next-line deprecation/deprecation
API,
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 { SDK_VERSION } from './version';

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
11 changes: 7 additions & 4 deletions packages/hub/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
export type {
Carrier,
// eslint-disable-next-line deprecation/deprecation
DomainAsCarrier,
Layer,
} from './hub';

export { addGlobalEventProcessor, Scope } from './scope';
export { Session } from './session';
export { SessionFlusher } from './sessionflusher';
Expand All @@ -10,8 +17,4 @@ export {
Hub,
makeMain,
setHubOnCarrier,
Carrier,
// eslint-disable-next-line deprecation/deprecation
DomainAsCarrier,
Layer,
} 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/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 eventFromMessage(this._options, message, level, hint);
}

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 @@ -69,7 +69,7 @@ export function eventFromException(options: Options, exception: unknown, hint?:
export function eventFromMessage(
options: Options,
message: string,
level: Severity = Severity.Info,
level: Severity = 'info' as Severity,
hint?: EventHint,
): PromiseLike<Event> {
const event: 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 @@ -40,7 +42,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 @@ -77,7 +77,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
2 changes: 1 addition & 1 deletion packages/serverless/src/awslambda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,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';
9 changes: 5 additions & 4 deletions packages/tracing/src/index.bundle.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export {
export type {
Breadcrumb,
Request,
SdkInfo,
Expand All @@ -13,7 +13,9 @@ export {
User,
} from '@sentry/types';

export { SeverityLevel } from '@sentry/utils';
export type { BrowserOptions, ReportDialogOptions } from '@sentry/browser';

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

export {
addGlobalEventProcessor,
Expand All @@ -37,8 +39,7 @@ export {
withScope,
} from '@sentry/browser';

export { BrowserOptions } from '@sentry/browser';
export { BrowserClient, ReportDialogOptions } from '@sentry/browser';
export { BrowserClient } from '@sentry/browser';
export {
defaultIntegrations,
forceLoad,
Expand Down
6 changes: 4 additions & 2 deletions packages/tracing/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { addExtensionMethods } from './hubextensions';
import * as Integrations from './integrations';

export type { RequestInstrumentationOptions } from './browser';
export type { SpanStatusType } from './span';

export { Integrations };

// This is already exported as part of `Integrations` above (and for the moment will remain so for
Expand All @@ -21,14 +24,13 @@ export { Integrations };
// For an example of of the new usage of BrowserTracing, see @sentry/nextjs index.client.ts
export { BrowserTracing } from './browser';

export { Span, SpanStatusType, spanStatusfromHttpCode } from './span';
export { Span, spanStatusfromHttpCode } from './span';
// eslint-disable-next-line deprecation/deprecation
export { SpanStatus } from './spanstatus';
export { Transaction } from './transaction';
export {
// TODO deprecate old name in v7
instrumentOutgoingRequests as registerRequestInstrumentation,
RequestInstrumentationOptions,
defaultRequestInstrumentationOptions,
} from './browser';
export { IdleTransaction } from './idletransaction';
Expand Down
Loading