Skip to content

Commit 96373fc

Browse files
committed
compile with strict mode
1 parent 42c6596 commit 96373fc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+3713
-12518
lines changed

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"eslintignore",
2525
"jsdelivr",
2626
"lage",
27+
"localstorage",
2728
"maxcdn",
2829
"ncaught",
2930
"npmrc",

package-lock.json

Lines changed: 3512 additions & 12326 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@
2828
"example/*"
2929
],
3030
"devDependencies": {
31-
"@typescript-eslint/eslint-plugin": "4.25.0",
32-
"@typescript-eslint/parser": "4.25.0",
31+
"@typescript-eslint/eslint-plugin": "4.26.0",
32+
"@typescript-eslint/parser": "4.26.0",
3333
"eslint": "7.27.0",
3434
"eslint-plugin-eslint-comments": "3.2.0",
3535
"eslint-plugin-eslint-plugin": "3.0.3",
36-
"eslint-plugin-import": "2.23.3",
36+
"eslint-plugin-import": "2.23.4",
3737
"eslint-plugin-jest": "24.3.6",
38-
"eslint-plugin-jsdoc": "35.0.0",
38+
"eslint-plugin-jsdoc": "35.1.2",
3939
"lage": "^0.29.3",
4040
"rimraf": "3.0.2",
41-
"typescript": "4.2.4"
41+
"typescript": "4.3.2"
4242
}
4343
}

packages/angularjs/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"extends": "../../tsconfig.json",
33
"compilerOptions": {
44
"outDir": "dist",
5-
"rootDir": "src"
5+
"rootDir": "src",
6+
"strict": false
67
},
78
"include": ["src"],
89
"types": ["angular", "angular-mock"]

packages/browser/src/plugins/BrowserErrorPlugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export class BrowserErrorPlugin implements IEventPlugin {
2424
if (exception) {
2525
context.event.type = "error";
2626

27-
if (!context.event.data[KnownEventDataKeys.Error]) {
27+
if (context.event.data && !context.event.data[KnownEventDataKeys.Error]) {
2828
const result = await this.parse(exception);
2929
if (result) {
3030
const exclusions = context.client.config.dataExclusions.concat(IgnoredErrorProperties);

packages/browser/src/plugins/BrowserGlobalHandlerPlugin.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export class BrowserGlobalHandlerPlugin implements IEventPlugin {
1010
public priority: number = 100;
1111
public name: string = "BrowserGlobalHandlerPlugin";
1212

13-
private _client: ExceptionlessClient = null;
13+
private _client: ExceptionlessClient | undefined;
1414

1515
public startup(context: PluginContext): Promise<void> {
1616
if (this._client) {
@@ -21,7 +21,7 @@ export class BrowserGlobalHandlerPlugin implements IEventPlugin {
2121

2222
// TODO: Discus if we want to unwire this handler in suspend?
2323
window.addEventListener("error", event => {
24-
void this._client.submitUnhandledException(this.getError(event), "onerror");
24+
void this._client?.submitUnhandledException(this.getError(event), "onerror");
2525
});
2626

2727
window.addEventListener("unhandledrejection", event => {
@@ -35,18 +35,18 @@ export class BrowserGlobalHandlerPlugin implements IEventPlugin {
3535
// eslint-disable-next-line no-empty
3636
} catch (ex) { }
3737

38-
void this._client.submitUnhandledException(error, "onunhandledrejection");
38+
void this._client?.submitUnhandledException(error, "onunhandledrejection");
3939
});
4040

4141

4242
if (typeof $ !== "undefined" && $(document)) {
4343
$(document).ajaxError((event: Event, xhr: { responseText: string, status: number }, settings: { data: unknown, url: string }, error: string) => {
4444
if (xhr.status === 404) {
4545
// TODO: Handle async
46-
void this._client.submitNotFound(settings.url);
46+
void this._client?.submitNotFound(settings.url);
4747
} else if (xhr.status !== 401) {
4848
// TODO: Handle async
49-
void this._client.createUnhandledException(new Error(error), "JQuery.ajaxError")
49+
void this._client?.createUnhandledException(new Error(error), "JQuery.ajaxError")
5050
.setSource(settings.url)
5151
.setProperty("status", xhr.status)
5252
.setProperty("request", settings.data)
@@ -69,12 +69,15 @@ export class BrowserGlobalHandlerPlugin implements IEventPlugin {
6969
let msg: string = message || event.error;
7070
if (msg) {
7171
const errorNameRegex: RegExp = /^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Aggregate|Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;
72-
const [_, errorName, errorMessage] = errorNameRegex.exec(msg);
73-
if (errorName) {
74-
name = errorName;
75-
}
76-
if (errorMessage) {
77-
msg = errorMessage;
72+
const regexResult = errorNameRegex.exec(msg);
73+
if (regexResult) {
74+
const [_, errorName, errorMessage] = regexResult;
75+
if (errorName) {
76+
name = errorName;
77+
}
78+
if (errorMessage) {
79+
msg = errorMessage;
80+
}
7881
}
7982
}
8083

packages/browser/src/plugins/BrowserLifeCyclePlugin.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export class BrowserLifeCyclePlugin implements IEventPlugin {
88
public priority: number = 105;
99
public name: string = "BrowserLifeCyclePlugin";
1010

11-
private _client: ExceptionlessClient = null;
11+
private _client: ExceptionlessClient | undefined;
1212

1313
public startup(context: PluginContext): Promise<void> {
1414
if (this._client) {
@@ -17,12 +17,12 @@ export class BrowserLifeCyclePlugin implements IEventPlugin {
1717

1818
this._client = context.client;
1919

20-
globalThis.addEventListener("beforeunload", () => void this._client.suspend());
20+
globalThis.addEventListener("beforeunload", () => void this._client?.suspend());
2121
document.addEventListener("visibilitychange", () => {
2222
if (document.visibilityState === 'visible') {
23-
void this._client.startup()
23+
void this._client?.startup()
2424
} else {
25-
void this._client.suspend()
25+
void this._client?.suspend()
2626
}
2727
});
2828

packages/browser/src/plugins/BrowserModuleInfoPlugin.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
export class BrowserModuleInfoPlugin implements IEventPlugin {
1212
public priority: number = 50;
1313
public name: string = "BrowserModuleInfoPlugin";
14-
private _modules: ModuleInfo[] = null;
14+
private _modules: ModuleInfo[] | undefined;
1515

1616
public startup(context: PluginContext): Promise<void> {
1717
if (!this._modules) {
@@ -22,17 +22,17 @@ export class BrowserModuleInfoPlugin implements IEventPlugin {
2222
}
2323

2424
public run(context: EventPluginContext): Promise<void> {
25-
const error = context.event.data[KnownEventDataKeys.Error];
26-
if (this._modules?.length > 0 && !error?.modules) {
25+
const error = context.event.data?.[KnownEventDataKeys.Error];
26+
if (error && !error?.modules && this._modules?.length) {
2727
error.modules = this._modules;
2828
}
2929

3030
return Promise.resolve();
3131
}
3232

33-
private getModules(): ModuleInfo[] {
33+
private getModules(): ModuleInfo[] | undefined {
3434
if (!document || !document.getElementsByTagName) {
35-
return null;
35+
return;
3636
}
3737

3838
const modules: ModuleInfo[] = [];
@@ -44,7 +44,7 @@ export class BrowserModuleInfoPlugin implements IEventPlugin {
4444
modules.push({
4545
module_id: index,
4646
name: scripts[index].src.split("?")[0],
47-
version: parseVersion(scripts[index].src),
47+
version: <string>parseVersion(scripts[index].src),
4848
});
4949
} else if (scripts[index].innerHTML) {
5050
modules.push({

packages/browser/src/plugins/BrowserRequestInfoPlugin.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ export class BrowserRequestInfoPlugin implements IEventPlugin {
1313
public name: string = "BrowserRequestInfoPlugin";
1414

1515
public run(context: EventPluginContext): Promise<void> {
16-
if (!context.event.data[KnownEventDataKeys.RequestInfo]) {
17-
const requestInfo: RequestInfo = this.getRequestInfo(context);
16+
if (context.event.data && !context.event.data[KnownEventDataKeys.RequestInfo]) {
17+
const requestInfo: RequestInfo | undefined = this.getRequestInfo(context);
1818
if (requestInfo) {
1919
if (isMatch(requestInfo.user_agent, context.client.config.userAgentBotPatterns)) {
2020
context.log.info("Cancelling event as the request user agent matches a known bot pattern");
@@ -28,9 +28,9 @@ export class BrowserRequestInfoPlugin implements IEventPlugin {
2828
return Promise.resolve();
2929
}
3030

31-
private getRequestInfo(context: EventPluginContext): RequestInfo {
31+
private getRequestInfo(context: EventPluginContext): RequestInfo | undefined {
3232
if (!document || !navigator || !location) {
33-
return null;
33+
return;
3434
}
3535

3636
const config = context.client.config;
@@ -47,7 +47,7 @@ export class BrowserRequestInfoPlugin implements IEventPlugin {
4747
};
4848

4949
if (config.includeCookies) {
50-
requestInfo.cookies = getCookies(document.cookie, exclusions);
50+
requestInfo.cookies = getCookies(document.cookie, exclusions) as Record<string, string>;
5151
}
5252

5353
if (config.includeQueryString) {

packages/browser/src/plugins/BrowserWrapFunctions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export class BrowserWrapFunctions implements IEventPlugin {
88
public priority: number = 110;
99
public name: string = "BrowserWrapFunctions";
1010

11-
private _client: ExceptionlessClient = null;
11+
private _client: ExceptionlessClient | undefined;
1212

1313
public startup(context: PluginContext): Promise<void> {
1414
if (this._client) {

0 commit comments

Comments
 (0)