|
1 | 1 | import * as eslintUtils from 'eslint-utils'; |
2 | 2 | import { TSESTree } from '../../ts-estree'; |
3 | 3 |
|
4 | | -type IsPunctuatorTokenWithValueFunction<Value extends string> = ( |
| 4 | +type IsSpecificTokenFunction<SpecificToken extends TSESTree.Token> = ( |
5 | 5 | token: TSESTree.Token, |
6 | | -) => token is TSESTree.PunctuatorToken & { value: Value }; |
| 6 | +) => token is SpecificToken; |
7 | 7 |
|
8 | | -type IsNotPunctuatorTokenWithValueFunction<Value extends string> = ( |
| 8 | +type IsNotSpecificTokenFunction<SpecificToken extends TSESTree.Token> = ( |
9 | 9 | token: TSESTree.Token, |
10 | | -) => token is Exclude< |
11 | | - TSESTree.Token, |
12 | | - TSESTree.PunctuatorToken & { value: Value } |
13 | | ->; |
| 10 | +) => token is Exclude<TSESTree.Token, SpecificToken>; |
| 11 | + |
| 12 | +type PunctuatorTokenWithValue<Value extends string> = |
| 13 | + TSESTree.PunctuatorToken & { value: Value }; |
| 14 | +type IsPunctuatorTokenWithValueFunction<Value extends string> = |
| 15 | + IsSpecificTokenFunction<PunctuatorTokenWithValue<Value>>; |
| 16 | +type IsNotPunctuatorTokenWithValueFunction<Value extends string> = |
| 17 | + IsNotSpecificTokenFunction<PunctuatorTokenWithValue<Value>>; |
14 | 18 |
|
15 | 19 | const isArrowToken = |
16 | 20 | eslintUtils.isArrowToken as IsPunctuatorTokenWithValueFunction<'=>'>; |
@@ -42,12 +46,10 @@ const isCommaToken = |
42 | 46 | const isNotCommaToken = |
43 | 47 | eslintUtils.isNotCommaToken as IsNotPunctuatorTokenWithValueFunction<','>; |
44 | 48 |
|
45 | | -const isCommentToken = eslintUtils.isCommentToken as ( |
46 | | - token: TSESTree.Token, |
47 | | -) => token is TSESTree.Comment; |
48 | | -const isNotCommentToken = eslintUtils.isNotCommentToken as ( |
49 | | - token: TSESTree.Token, |
50 | | -) => token is Exclude<TSESTree.Token, TSESTree.Comment>; |
| 49 | +const isCommentToken = |
| 50 | + eslintUtils.isCommentToken as IsSpecificTokenFunction<TSESTree.Comment>; |
| 51 | +const isNotCommentToken = |
| 52 | + eslintUtils.isNotCommentToken as IsNotSpecificTokenFunction<TSESTree.Comment>; |
51 | 53 |
|
52 | 54 | const isOpeningBraceToken = |
53 | 55 | eslintUtils.isOpeningBraceToken as IsPunctuatorTokenWithValueFunction<'{'>; |
|
0 commit comments