Skip to content

Commit 59137f9

Browse files
committed
fix
1 parent 5d2c64b commit 59137f9

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

lib/utils/ts-utils/ts-ast.js

+25-4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ const { inferRuntimeTypeFromTypeNode } = require('./ts-types')
1414
* @typedef {import('../index').ComponentTypeEmit} ComponentTypeEmit
1515
*/
1616

17+
const noop = Function.prototype
18+
1719
module.exports = {
1820
isTypeNode,
1921
flattenTypeNodes,
@@ -25,17 +27,21 @@ module.exports = {
2527
}
2628

2729
/**
28-
* @param {TSESTreeNode | ASTNode} node
29-
* @returns {node is TSESTreeTypeNode}
30+
* @param {ASTNode} node
31+
* @returns {node is TypeNode}
3032
*/
3133
function isTypeNode(node) {
32-
return (
34+
if (
35+
node.type === 'TSAbstractKeyword' ||
3336
node.type === 'TSAnyKeyword' ||
37+
node.type === 'TSAsyncKeyword' ||
3438
node.type === 'TSArrayType' ||
3539
node.type === 'TSBigIntKeyword' ||
3640
node.type === 'TSBooleanKeyword' ||
3741
node.type === 'TSConditionalType' ||
3842
node.type === 'TSConstructorType' ||
43+
node.type === 'TSDeclareKeyword' ||
44+
node.type === 'TSExportKeyword' ||
3945
node.type === 'TSFunctionType' ||
4046
node.type === 'TSImportType' ||
4147
node.type === 'TSIndexedAccessType' ||
@@ -50,7 +56,13 @@ function isTypeNode(node) {
5056
node.type === 'TSNumberKeyword' ||
5157
node.type === 'TSObjectKeyword' ||
5258
node.type === 'TSOptionalType' ||
59+
node.type === 'TSQualifiedName' ||
60+
node.type === 'TSPrivateKeyword' ||
61+
node.type === 'TSProtectedKeyword' ||
62+
node.type === 'TSPublicKeyword' ||
63+
node.type === 'TSReadonlyKeyword' ||
5364
node.type === 'TSRestType' ||
65+
node.type === 'TSStaticKeyword' ||
5466
node.type === 'TSStringKeyword' ||
5567
node.type === 'TSSymbolKeyword' ||
5668
node.type === 'TSTemplateLiteralType' ||
@@ -65,7 +77,16 @@ function isTypeNode(node) {
6577
node.type === 'TSUnionType' ||
6678
node.type === 'TSUnknownKeyword' ||
6779
node.type === 'TSVoidKeyword'
68-
)
80+
) {
81+
/** @type {TypeNode['type']} for type check */
82+
const type = node.type
83+
noop(type)
84+
return true
85+
}
86+
/** @type {Exclude<ASTNode['type'], TypeNode['type']>} for type check */
87+
const type = node.type
88+
noop(type)
89+
return false
6990
}
7091

7192
/**

typings/eslint-plugin-vue/util-types/ast/ts-ast.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,11 @@ export interface TSFunctionType extends TSFunctionSignatureBase {
9292
type: 'TSFunctionType'
9393
}
9494

95+
type TypeNodeTypes = `${TSESTree.TypeNode['type']}`
96+
9597
export type TypeNode =
9698
| (HasParentNode & {
97-
type: Exclude<
98-
TSESTree.TypeNode['type'],
99-
'TSFunctionType' | 'TSLiteralType'
100-
>
99+
type: Exclude<TypeNodeTypes, 'TSFunctionType' | 'TSLiteralType'>
101100
})
102101
| TSFunctionType
103102
| TSLiteralType

0 commit comments

Comments
 (0)