@@ -165,7 +165,9 @@ export function getLastModifier(node: ts.Node): ts.Modifier | null {
165
165
* @param token the TypeScript token
166
166
* @returns is comma
167
167
*/
168
- export function isComma ( token : ts . Node ) : boolean {
168
+ export function isComma (
169
+ token : ts . Node ,
170
+ ) : token is ts . Token < ts . SyntaxKind . CommaToken > {
169
171
return token . kind === SyntaxKind . CommaToken ;
170
172
}
171
173
@@ -186,7 +188,7 @@ export function isComment(node: ts.Node): boolean {
186
188
* @param node the TypeScript node
187
189
* @returns is JSDoc comment
188
190
*/
189
- export function isJSDocComment ( node : ts . Node ) : boolean {
191
+ export function isJSDocComment ( node : ts . Node ) : node is ts . JSDoc {
190
192
return node . kind === SyntaxKind . JSDocComment ;
191
193
}
192
194
@@ -285,7 +287,7 @@ export function getRange(node: ts.Node, ast: ts.SourceFile): [number, number] {
285
287
* @param node the ts.Node
286
288
* @returns is a token
287
289
*/
288
- export function isToken ( node : ts . Node ) : boolean {
290
+ export function isToken ( node : ts . Node ) : node is ts . Token < ts . TokenSyntaxKind > {
289
291
return (
290
292
node . kind >= SyntaxKind . FirstToken && node . kind <= SyntaxKind . LastToken
291
293
) ;
@@ -434,7 +436,9 @@ export function unescapeStringLiteralText(text: string): string {
434
436
* @param node ts.Node to be checked
435
437
* @returns is Computed Property
436
438
*/
437
- export function isComputedProperty ( node : ts . Node ) : boolean {
439
+ export function isComputedProperty (
440
+ node : ts . Node ,
441
+ ) : node is ts . ComputedPropertyName {
438
442
return node . kind === SyntaxKind . ComputedPropertyName ;
439
443
}
440
444
@@ -471,15 +475,11 @@ export function isChildUnwrappableOptionalChain(
471
475
| ts . NonNullExpression ,
472
476
child : TSESTree . Node ,
473
477
) : boolean {
474
- if (
478
+ return (
475
479
isChainExpression ( child ) &&
476
480
// (x?.y).z is semantically different, and as such .z is no longer optional
477
481
node . expression . kind !== ts . SyntaxKind . ParenthesizedExpression
478
- ) {
479
- return true ;
480
- }
481
-
482
- return false ;
482
+ ) ;
483
483
}
484
484
485
485
/**
@@ -586,7 +586,7 @@ export function getTokenType(
586
586
* @returns the converted Token
587
587
*/
588
588
export function convertToken (
589
- token : ts . Node ,
589
+ token : ts . Token < ts . TokenSyntaxKind > ,
590
590
ast : ts . SourceFile ,
591
591
) : TSESTree . Token {
592
592
const start =
0 commit comments