Skip to content

Commit 36f81db

Browse files
committed
TS tweaks
1 parent e140050 commit 36f81db

File tree

2 files changed

+24
-17
lines changed

2 files changed

+24
-17
lines changed

index.d.ts

+24-16
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,97 @@
1+
import {
2+
BrowserWindow,
3+
WebviewTag,
4+
ContextMenuParams,
5+
MenuItem,
6+
Event as ElectronEvent
7+
} from 'electron';
8+
19
export interface Labels {
210
/**
311
* @default 'Cut'
412
*/
5-
cut?: string;
13+
readonly cut?: string;
614

715
/**
816
* @default 'Copy'
917
*/
10-
copy?: string;
18+
readonly copy?: string;
1119

1220
/**
1321
* @default 'Paste'
1422
*/
15-
paste?: string;
23+
readonly paste?: string;
1624

1725
/**
1826
* @default 'Save Image'
1927
*/
20-
save?: string;
28+
readonly save?: string;
2129

2230
/**
2331
* @default 'Save Image As…'
2432
*/
25-
saveImageAs?: string;
33+
readonly saveImageAs?: string;
2634

2735
/**
2836
* @default 'Copy Link'
2937
*/
30-
copyLink?: string;
38+
readonly copyLink?: string;
3139

3240
/**
3341
* @default 'Copy Image Address'
3442
*/
35-
copyImageAddress?: string;
43+
readonly copyImageAddress?: string;
3644

3745
/**
3846
* @default 'Inspect Element'
3947
*/
40-
inspect?: string;
48+
readonly inspect?: string;
4149
}
4250

4351
export interface Options {
4452
/**
4553
* Window or WebView to add the context menu to.
4654
* When not specified, the context menu will be added to all existing and new windows.
4755
*/
48-
window?: Electron.BrowserWindow | Electron.WebviewTag;
56+
readonly window?: BrowserWindow | WebviewTag;
4957

5058
/**
5159
* Should return an array of [menu items](https://electronjs.org/docs/api/menu-item) to be prepended to the context menu.
5260
*/
53-
prepend?: (params: Electron.ContextMenuParams, browserWindow: Electron.BrowserWindow | Electron.WebviewTag) => Electron.MenuItem[];
61+
readonly prepend?: (params: ContextMenuParams, browserWindow: BrowserWindow | WebviewTag) => MenuItem[];
5462

5563
/**
5664
* Should return an array of [menu items](https://electronjs.org/docs/api/menu-item) to be appended to the context menu.
5765
*/
58-
append?: (param: Electron.ContextMenuParams, browserWindow: Electron.BrowserWindow | Electron.WebviewTag) => Electron.MenuItem[];
66+
readonly append?: (param: ContextMenuParams, browserWindow: BrowserWindow | WebviewTag) => MenuItem[];
5967

6068
/**
6169
* Show the `Copy Image Address` menu item when right-clicking on an image.
6270
*
6371
* @default false
6472
*/
65-
showCopyImageAddress?: boolean;
73+
readonly showCopyImageAddress?: boolean;
6674

6775
/**
6876
* Show the `Save Image As…` menu item when right-clicking on an image.
6977
*
7078
* @default false
7179
*/
72-
showSaveImageAs?: boolean;
80+
readonly showSaveImageAs?: boolean;
7381

7482
/**
7583
* Force enable or disable the `Inspect Element` menu item.
7684
*
7785
* Default: [Only in development](https://github.com/sindresorhus/electron-is-dev)
7886
*/
79-
showInspectElement?: boolean;
87+
readonly showInspectElement?: boolean;
8088

8189
/**
8290
* Overwrite labels for the default menu items. Useful for i18n.
8391
*
8492
* @default {}
8593
*/
86-
labels?: Labels;
94+
readonly labels?: Labels;
8795

8896
/**
8997
* Determines whether or not to show the menu.
@@ -94,7 +102,7 @@ export interface Options {
94102
* // Doesn't show the menu if the element is editable
95103
* shouldShowMenu: (event, params) => !params.isEditable
96104
*/
97-
shouldShowMenu?: (event: Electron.Event, params: Electron.ContextMenuParams) => boolean;
105+
readonly shouldShowMenu?: (event: ElectronEvent, params: ContextMenuParams) => boolean;
98106
}
99107

100108
/**

index.test-d.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {expectType} from 'tsd-check';
2-
import {BrowserWindow} from 'electron';
32
import contextMenu from '.';
43

54
expectType<void>(contextMenu());

0 commit comments

Comments
 (0)