Skip to content

Commit 7499d74

Browse files
committed
Make type typechecker happy
1 parent 5fe843e commit 7499d74

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

imlformat/iml-prettier.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,20 @@ function trim_parentheses(s: string): string {
178178
return s;
179179
}
180180

181-
function comments(cur, options: Options): Doc[] {
181+
interface Position {
182+
pos_fname: string;
183+
pos_cnum: number;
184+
pos_lnum: number;
185+
pos_bol: number;
186+
}
187+
188+
interface Location {
189+
loc_start: Position;
190+
loc_ghost: boolean;
191+
loc_end: Position;
192+
}
193+
194+
function comments(cur: Location, options: Options): Doc[] {
182195
if (cur && cur.loc_start.pos_cnum >= 0) {
183196
const last = options.last_loc;
184197
if (last) {
@@ -203,8 +216,8 @@ function comments(cur, options: Options): Doc[] {
203216
return [];
204217
}
205218

206-
function gobble_line_comment(pos, options: Options): Doc[] {
207-
let i = pos.loc_end.pos_cnum;
219+
function gobble_line_comment(loc: Location, options: Options): Doc[] {
220+
let i = loc.loc_end.pos_cnum;
208221
const src = options.originalText as string;
209222
let comment_from = undefined;
210223
while (src[i] != '\n' && i < src.length - 1) {
@@ -228,8 +241,8 @@ function gobble_line_comment(pos, options: Options): Doc[] {
228241
tmp += src[i] + src[i + 1];
229242
r.push(tmp);
230243
tmp = "";
231-
options.last_loc = pos;
232-
options.last_loc.loc_end.pos_cnum = i;
244+
options.last_loc = loc;
245+
(options.last_loc as Location).loc_end.pos_cnum = i;
233246
}
234247
else
235248
i++;

0 commit comments

Comments
 (0)