Skip to content

Commit

Permalink
js: Export variables instead of setting them on window.
Browse files Browse the repository at this point in the history
  • Loading branch information
priyank-p authored and timabbott committed Jun 22, 2021
1 parent 5f07c06 commit 81e2c38
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
3 changes: 2 additions & 1 deletion static/js/blueslip.ts
Expand Up @@ -12,6 +12,7 @@ import * as blueslip_stacktrace from "./blueslip_stacktrace";
import {page_params} from "./page_params";
import * as ui_report from "./ui_report";

export let last_stacktrace: string | undefined;
if (Error.stackTraceLimit !== undefined) {
Error.stackTraceLimit = 100000;
}
Expand Down Expand Up @@ -169,7 +170,7 @@ function report_error(
// = False on your development server, or else this code path
// won't execute to begin with -- useful for testing
// (un)minification.)
window.last_stacktrace = stack;
last_stacktrace = stack;
}
}

Expand Down
5 changes: 0 additions & 5 deletions static/js/global.d.ts
Expand Up @@ -8,8 +8,3 @@ declare let zulip_test: any;
interface JQuery {
expectOne(): JQuery;
}

interface Window {
last_stacktrace: string;
page_params_parse_time: number;
}
2 changes: 1 addition & 1 deletion static/js/page_params.ts
Expand Up @@ -14,7 +14,7 @@ export const page_params: {
translation_data: Record<string, string>;
} = $("#page-params").remove().data("params");
const t2 = performance.now();
window.page_params_parse_time = t2 - t1;
export const page_params_parse_time = t2 - t1;
if (!page_params) {
throw new Error("Missing page-params");
}
3 changes: 2 additions & 1 deletion static/js/zulip_test.js
Expand Up @@ -12,5 +12,6 @@ export {get_stream_id, get_sub, get_subscriber_count} from "./stream_data";
export {get_by_user_id as get_person_by_user_id, get_user_id_from_name} from "./people";
export {last_visible as last_visible_row, id as row_id} from "./rows";
export {cancel as cancel_compose} from "./compose_actions";
export {page_params} from "./page_params";
export {page_params, page_params_parse_time} from "./page_params";
export {initiate as initiate_reload} from "./reload";
export {last_stacktrace} from "./blueslip";

0 comments on commit 81e2c38

Please sign in to comment.