Skip to content

Commit 3a7a7be

Browse files
committed
👍 allows readonly array for arguments
1 parent 49de961 commit 3a7a7be

File tree

3 files changed

+24
-24
lines changed

3 files changed

+24
-24
lines changed

autocmd/_utils.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type { AutocmdEvent, DefineOptions, RemoveOptions } from "./types.ts";
22

33
export function buildDefineExpr(
4-
event: AutocmdEvent | AutocmdEvent[],
5-
pat: string | string[],
4+
event: AutocmdEvent | readonly AutocmdEvent[],
5+
pat: string | readonly string[],
66
cmd: string,
77
options: DefineOptions = {},
88
): string {
@@ -13,12 +13,12 @@ export function buildDefineExpr(
1313
if (Array.isArray(event)) {
1414
terms.push(event.join(","));
1515
} else {
16-
terms.push(event);
16+
terms.push(event as AutocmdEvent);
1717
}
1818
if (Array.isArray(pat)) {
1919
terms.push(pat.join(","));
2020
} else {
21-
terms.push(pat);
21+
terms.push(pat as string);
2222
}
2323
if (options.once) {
2424
terms.push("++once");
@@ -31,8 +31,8 @@ export function buildDefineExpr(
3131
}
3232

3333
export function buildRemoveExpr(
34-
event?: "*" | AutocmdEvent | AutocmdEvent[],
35-
pat?: string | string[],
34+
event?: "*" | AutocmdEvent | readonly AutocmdEvent[],
35+
pat?: string | readonly string[],
3636
options: RemoveOptions = {},
3737
): string {
3838
const terms = ["au!"];
@@ -43,13 +43,13 @@ export function buildRemoveExpr(
4343
if (Array.isArray(event)) {
4444
terms.push(event.join(","));
4545
} else {
46-
terms.push(event);
46+
terms.push(event as AutocmdEvent);
4747
}
4848
if (pat) {
4949
if (Array.isArray(pat)) {
5050
terms.push(pat.join(","));
5151
} else {
52-
terms.push(pat);
52+
terms.push(pat as string);
5353
}
5454
}
5555
}

autocmd/common.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ import { buildDefineExpr, buildRemoveExpr } from "./_utils.ts";
4141
*/
4242
export async function define(
4343
denops: Denops,
44-
event: AutocmdEvent | AutocmdEvent[],
45-
pat: string | string[],
44+
event: AutocmdEvent | readonly AutocmdEvent[],
45+
pat: string | readonly string[],
4646
cmd: string,
4747
options: DefineOptions = {},
4848
): Promise<void> {
@@ -76,8 +76,8 @@ export async function define(
7676
*/
7777
export async function remove(
7878
denops: Denops,
79-
event?: "*" | AutocmdEvent | AutocmdEvent[],
80-
pat?: string | string[],
79+
event?: "*" | AutocmdEvent | readonly AutocmdEvent[],
80+
pat?: string | readonly string[],
8181
options: RemoveOptions = {},
8282
): Promise<void> {
8383
const expr = buildRemoveExpr(event, pat, options);
@@ -108,8 +108,8 @@ export async function remove(
108108
*/
109109
export async function list(
110110
denops: Denops,
111-
event?: "*" | AutocmdEvent | AutocmdEvent[],
112-
pat?: string | string[],
111+
event?: "*" | AutocmdEvent | readonly AutocmdEvent[],
112+
pat?: string | readonly string[],
113113
options: ListOptions = {},
114114
): Promise<unknown> {
115115
const terms = ["au"];
@@ -120,13 +120,13 @@ export async function list(
120120
if (Array.isArray(event)) {
121121
terms.push(event.join(","));
122122
} else {
123-
terms.push(event);
123+
terms.push(event as AutocmdEvent);
124124
}
125125
if (pat) {
126126
if (Array.isArray(pat)) {
127127
terms.push(pat.join(","));
128128
} else {
129-
terms.push(pat);
129+
terms.push(pat as string);
130130
}
131131
}
132132
}
@@ -155,7 +155,7 @@ export async function list(
155155
*/
156156
export async function emit(
157157
denops: Denops,
158-
event: AutocmdEvent | AutocmdEvent[],
158+
event: AutocmdEvent | readonly AutocmdEvent[],
159159
fname?: string,
160160
options: EmitOptions = {},
161161
): Promise<unknown> {
@@ -169,7 +169,7 @@ export async function emit(
169169
if (Array.isArray(event)) {
170170
terms.push(event.join(","));
171171
} else {
172-
terms.push(event);
172+
terms.push(event as AutocmdEvent);
173173
}
174174
if (fname) {
175175
terms.push(fname);
@@ -199,7 +199,7 @@ export async function emit(
199199
*/
200200
export async function emitAll(
201201
denops: Denops,
202-
event: AutocmdEvent | AutocmdEvent[],
202+
event: AutocmdEvent | readonly AutocmdEvent[],
203203
fname?: string,
204204
options: EmitOptions = {},
205205
): Promise<unknown> {
@@ -213,7 +213,7 @@ export async function emitAll(
213213
if (Array.isArray(event)) {
214214
terms.push(event.join(","));
215215
} else {
216-
terms.push(event);
216+
terms.push(event as AutocmdEvent);
217217
}
218218
if (fname) {
219219
terms.push(fname);

autocmd/group.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ class GroupHelper {
7272
* Define an autocmd
7373
*/
7474
define(
75-
event: AutocmdEvent | AutocmdEvent[],
76-
pat: string | string[],
75+
event: AutocmdEvent | readonly AutocmdEvent[],
76+
pat: string | readonly string[],
7777
cmd: string,
7878
options: GroupDefineOptions = {},
7979
): void {
@@ -84,8 +84,8 @@ class GroupHelper {
8484
* Remove an autocmd
8585
*/
8686
remove(
87-
event?: "*" | AutocmdEvent | AutocmdEvent[],
88-
pat?: string | string[],
87+
event?: "*" | AutocmdEvent | readonly AutocmdEvent[],
88+
pat?: string | readonly string[],
8989
options: GroupRemoveOptions = {},
9090
): void {
9191
this.#commands.push(buildRemoveExpr(event, pat, options));

0 commit comments

Comments
 (0)