Skip to content

Commit 99870c4

Browse files
authored
remove usage of any
Signed-off-by: Matthew Peveler <[email protected]>
1 parent e4f1677 commit 99870c4

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

src/tokenizer.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -269,11 +269,11 @@ function getCustomParam(state: State, paramTypes: ParamTypes): string | null | u
269269
}
270270

271271
function scanParameter(state: State, dialect: Dialect, paramTypes: ParamTypes): Token {
272-
const curCh: any = state.input[state.start];
272+
const curCh = state.input[state.start];
273273
const nextChar = peek(state);
274274
let matched = false;
275275

276-
if (paramTypes.numbered && paramTypes.numbered.length && paramTypes.numbered.includes(curCh)) {
276+
if (paramTypes.numbered?.length && paramTypes.numbered.some((type) => type === curCh)) {
277277
const endIndex = state.input
278278
.slice(state.start + 1)
279279
.split('')
@@ -293,19 +293,14 @@ function scanParameter(state: State, dialect: Dialect, paramTypes: ParamTypes):
293293
}
294294
}
295295

296-
if (!matched && paramTypes.named && paramTypes.named.length && paramTypes.named.includes(curCh)) {
296+
if (!matched && paramTypes.named?.length && paramTypes.named.some((type) => type === curCh)) {
297297
if (!isQuotedIdentifier(nextChar, dialect)) {
298298
while (isAlphaNumeric(peek(state))) read(state);
299299
matched = true;
300300
}
301301
}
302302

303-
if (
304-
!matched &&
305-
paramTypes.quoted &&
306-
paramTypes.quoted.length &&
307-
paramTypes.quoted.includes(curCh)
308-
) {
303+
if (!matched && paramTypes.quoted?.length && paramTypes.quoted.some((type) => type === curCh)) {
309304
if (isQuotedIdentifier(nextChar, dialect)) {
310305
const quoteChar = read(state) as string;
311306
// end when we reach the end quote
@@ -462,32 +457,37 @@ function isString(ch: Char, dialect: Dialect): boolean {
462457
return stringStart.includes(ch);
463458
}
464459

465-
function isCustomParam(state: State, paramTypes: ParamTypes): boolean | undefined {
466-
return paramTypes?.custom?.some((regex) => {
460+
function isCustomParam(
461+
state: State,
462+
customParamType: NonNullable<ParamTypes['custom']>,
463+
): boolean | undefined {
464+
return customParamType.some((regex) => {
467465
const reg = new RegExp(`^(?:${regex})`, 'uy');
468466
return reg.test(state.input.slice(state.start));
469467
});
470468
}
471469

472470
function isParameter(ch: Char, state: State, paramTypes: ParamTypes): boolean {
473-
const curCh: any = ch;
471+
if (!ch) {
472+
return false;
473+
}
474474
const nextChar = peek(state);
475475
if (paramTypes.positional && ch === '?') return true;
476476

477-
if (paramTypes.numbered && paramTypes.numbered.length && paramTypes.numbered.includes(curCh)) {
477+
if (paramTypes.numbered?.length && paramTypes.numbered.some((type) => ch === type)) {
478478
if (nextChar !== null && !isNaN(Number(nextChar))) {
479479
return true;
480480
}
481481
}
482482

483483
if (
484-
(paramTypes.named && paramTypes.named.length && paramTypes.named.includes(curCh)) ||
485-
(paramTypes.quoted && paramTypes.quoted.length && paramTypes.quoted.includes(curCh))
484+
(paramTypes.named?.length && paramTypes.named.some((type) => type === ch)) ||
485+
(paramTypes.quoted?.length && paramTypes.quoted.some((type) => type === ch))
486486
) {
487487
return true;
488488
}
489489

490-
if (paramTypes.custom && paramTypes.custom.length && isCustomParam(state, paramTypes)) {
490+
if (paramTypes.custom?.length && isCustomParam(state, paramTypes.custom)) {
491491
return true;
492492
}
493493

0 commit comments

Comments
 (0)