Skip to content

Commit a9b1082

Browse files
committed
Augment the window interface instead of declaring a constant
1 parent 8470eac commit a9b1082

File tree

8 files changed

+15
-18
lines changed

8 files changed

+15
-18
lines changed

js/edit/edit.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import './editor';
22
import './tabs';
33
import './shortcode';
4-
import { window } from '../types';
54

65
document.addEventListener('DOMContentLoaded', () => {
76
const form = document.getElementById('snippet-form');

js/edit/editor.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import '../editor-lib';
2-
import { window } from '../types'
32

43
window.code_snippets_editor = (({ codeEditor }) => {
54
const textarea = document.getElementById('snippet_code');

js/edit/tabs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { SnippetType, window } from '../types';
1+
import { SnippetType } from '../types';
22
import { EditorConfiguration } from 'codemirror';
33

44
(editor => {

js/edit/tags.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import tagger from '@jcubic/tagger';
2-
import { window } from '../types'
32

43
(tags => {
54
const tags_field = document.getElementById('snippet_tags');

js/manage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Snippet, window } from './types';
1+
import { Snippet } from './types';
22

33
type SuccessCallback = (response: { success: boolean, data?: unknown }) => void;
44

js/settings/editor-preview.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import '../editor-lib';
2-
import { EditorOption, window } from '../types';
2+
import { EditorOption } from '../types';
33

44
const { codeEditor } = window.wp;
55
const editor_settings: EditorOption[] = window.code_snippets_editor_settings;

js/settings/tabs.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { window } from '../types'
2-
31
const page = document.querySelector('.wrap');
42
const tabs_wrapper = document.getElementById('settings-sections-tabs');
53
const http_referer = document.querySelector('input[name=_wp_http_referer]') as HTMLInputElement;

js/types.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,16 @@ export interface Snippet {
4242
type: SnippetType;
4343
}
4444

45-
export declare const window: Window & {
46-
pagenow: string;
47-
ajaxurl: string;
48-
wp: WordPressUtils;
49-
code_snippets_tags: { allow_spaces: boolean, available_tags: string[] };
50-
code_snippets_editor?: CodeEditorInstance;
51-
code_snippets_editor_preview?: CodeEditorInstance;
52-
code_snippets_editor_settings: EditorOption[];
53-
code_snippets_edit_i18n: Record<string, string>;
54-
code_snippets_manage_i18n: Record<string, string>;
45+
declare global {
46+
interface Window {
47+
pagenow: string;
48+
ajaxurl: string;
49+
wp: WordPressUtils;
50+
code_snippets_tags: { allow_spaces: boolean, available_tags: string[] };
51+
code_snippets_editor?: CodeEditorInstance;
52+
code_snippets_editor_preview?: CodeEditorInstance;
53+
code_snippets_editor_settings: EditorOption[];
54+
code_snippets_edit_i18n: Record<string, string>;
55+
code_snippets_manage_i18n: Record<string, string>;
56+
}
5557
}

0 commit comments

Comments
 (0)