@@ -27,7 +27,7 @@ const {
2727 * @typedef {import('@typescript-eslint/types').TSESTree.TSConstructSignatureDeclaration } TSConstructSignatureDeclaration
2828 * @typedef {import('@typescript-eslint/types').TSESTree.TSImportEqualsDeclaration } TSImportEqualsDeclaration
2929 * @typedef {import('@typescript-eslint/types').TSESTree.TSAbstractMethodDefinition } TSAbstractMethodDefinition
30- * @typedef {import('@typescript-eslint/types').TSESTree.TSAbstractClassProperty } TSAbstractClassProperty
30+ * @typedef {import('@typescript-eslint/types').TSESTree.TSAbstractPropertyDefinition } TSAbstractPropertyDefinition
3131 * @typedef {import('@typescript-eslint/types').TSESTree.TSEnumMember } TSEnumMember
3232 * @typedef {import('@typescript-eslint/types').TSESTree.TSPropertySignature } TSPropertySignature
3333 * @typedef {import('@typescript-eslint/types').TSESTree.TSIndexSignature } TSIndexSignature
@@ -50,12 +50,13 @@ const {
5050 * @typedef {import('@typescript-eslint/types').TSESTree.TSOptionalType } TSOptionalType
5151 * @typedef {import('@typescript-eslint/types').TSESTree.TSNonNullExpression } TSNonNullExpression
5252 * @typedef {import('@typescript-eslint/types').TSESTree.JSXChild } JSXChild
53+ * @typedef {import('@typescript-eslint/types').TSESTree.TypeNode } TypeNode
5354 *
5455 */
5556/**
56- * Perhaps this node will be deprecated in the future.
57- * It was present in @typescript-eslint/parser@4.1.0.
58- * @typedef {import('@typescript-eslint/types').TSESTree.ClassProperty } ClassProperty
57+ * Deprecated in @typescript-eslint/parser v5
58+ * @typedef { import(' @typescript-eslint/types').TSESTree.PropertyDefinition } ClassProperty
59+ * @typedef {import('@typescript-eslint/types').TSESTree.TSAbstractPropertyDefinition } TSAbstractClassProperty
5960 */
6061
6162module . exports = {
@@ -203,6 +204,7 @@ function defineVisitor({
203204 * | TSConstructSignatureDeclaration
204205 * | TSImportEqualsDeclaration
205206 * | TSAbstractMethodDefinition
207+ * | TSAbstractPropertyDefinition
206208 * | TSAbstractClassProperty
207209 * | TSEnumMember
208210 * | ClassProperty
@@ -211,10 +213,80 @@ function defineVisitor({
211213 * | TSMethodSignature} node
212214 */
213215 [ 'TSTypeAliasDeclaration, TSCallSignatureDeclaration, TSConstructSignatureDeclaration, TSImportEqualsDeclaration,' +
214- 'TSAbstractMethodDefinition, TSAbstractClassProperty, TSEnumMember, ClassProperty,' +
215- 'TSPropertySignature, TSIndexSignature, TSMethodSignature' ] ( node ) {
216+ 'TSAbstractMethodDefinition, TSAbstractPropertyDefinition, TSEnumMember,' +
217+ 'TSPropertySignature, TSIndexSignature, TSMethodSignature,' +
218+ // Deprecated in @typescript -eslint/parser v5
219+ 'ClassProperty, TSAbstractClassProperty' ] ( node ) {
216220 processSemicolons ( node )
217221 } ,
222+ /**
223+ * @param {TSESTreeNode } node
224+ */
225+ // eslint-disable-next-line complexity -- ignore
226+ '*[type=/^TS/]' ( node ) {
227+ if (
228+ node . type !== 'TSAnyKeyword' &&
229+ node . type !== 'TSArrayType' &&
230+ node . type !== 'TSBigIntKeyword' &&
231+ node . type !== 'TSBooleanKeyword' &&
232+ node . type !== 'TSConditionalType' &&
233+ node . type !== 'TSConstructorType' &&
234+ node . type !== 'TSFunctionType' &&
235+ node . type !== 'TSImportType' &&
236+ node . type !== 'TSIndexedAccessType' &&
237+ node . type !== 'TSInferType' &&
238+ node . type !== 'TSIntersectionType' &&
239+ node . type !== 'TSIntrinsicKeyword' &&
240+ node . type !== 'TSLiteralType' &&
241+ node . type !== 'TSMappedType' &&
242+ node . type !== 'TSNamedTupleMember' &&
243+ node . type !== 'TSNeverKeyword' &&
244+ node . type !== 'TSNullKeyword' &&
245+ node . type !== 'TSNumberKeyword' &&
246+ node . type !== 'TSObjectKeyword' &&
247+ node . type !== 'TSOptionalType' &&
248+ node . type !== 'TSRestType' &&
249+ node . type !== 'TSStringKeyword' &&
250+ node . type !== 'TSSymbolKeyword' &&
251+ node . type !== 'TSTemplateLiteralType' &&
252+ node . type !== 'TSThisType' &&
253+ node . type !== 'TSTupleType' &&
254+ node . type !== 'TSTypeLiteral' &&
255+ node . type !== 'TSTypeOperator' &&
256+ node . type !== 'TSTypePredicate' &&
257+ node . type !== 'TSTypeQuery' &&
258+ node . type !== 'TSTypeReference' &&
259+ node . type !== 'TSUndefinedKeyword' &&
260+ node . type !== 'TSUnionType' &&
261+ node . type !== 'TSUnknownKeyword' &&
262+ node . type !== 'TSVoidKeyword'
263+ ) {
264+ return
265+ }
266+ /** @type {TypeNode } */
267+ const typeNode = node
268+ if ( /** @type {any } */ ( typeNode . parent ) . type === 'TSParenthesizedType' ) {
269+ return
270+ }
271+ // Process parentheses.
272+ let leftToken = tokenStore . getTokenBefore ( node )
273+ let rightToken = tokenStore . getTokenAfter ( node )
274+ let firstToken = tokenStore . getFirstToken ( node )
275+
276+ while (
277+ leftToken &&
278+ rightToken &&
279+ isOpeningParenToken ( leftToken ) &&
280+ isClosingParenToken ( rightToken )
281+ ) {
282+ setOffset ( firstToken , 1 , leftToken )
283+ setOffset ( rightToken , 0 , leftToken )
284+
285+ firstToken = leftToken
286+ leftToken = tokenStore . getTokenBefore ( leftToken )
287+ rightToken = tokenStore . getTokenAfter ( rightToken )
288+ }
289+ } ,
218290 /**
219291 * Process type annotation
220292 *
@@ -535,15 +607,6 @@ function defineVisitor({
535607 setOffset ( typeTokens . firstToken , offset , firstToken )
536608 }
537609 } ,
538- TSParenthesizedType ( node ) {
539- // (T)
540- processNodeList (
541- [ node . typeAnnotation ] ,
542- tokenStore . getFirstToken ( node ) ,
543- tokenStore . getLastToken ( node ) ,
544- 1
545- )
546- } ,
547610 TSMappedType ( node ) {
548611 // {[key in foo]: bar}
549612 const leftBraceToken = tokenStore . getFirstToken ( node )
@@ -1026,12 +1089,12 @@ function defineVisitor({
10261089 * // ^^^^^^^
10271090 * ```
10281091 *
1029- * @param {TSAbstractMethodDefinition | TSAbstractClassProperty | TSEnumMember | ClassProperty } node
1092+ * @param {TSAbstractMethodDefinition | TSAbstractPropertyDefinition | TSEnumMember | TSAbstractClassProperty | ClassProperty } node
10301093 *
10311094 */
1032- 'TSAbstractMethodDefinition, TSAbstractClassProperty , TSEnumMember, ClassProperty' (
1033- node
1034- ) {
1095+ [ 'TSAbstractMethodDefinition, TSAbstractPropertyDefinition , TSEnumMember,' +
1096+ // Deprecated in @typescript -eslint/parser v5
1097+ 'ClassProperty, TSAbstractClassProperty' ] ( node ) {
10351098 const { keyNode, valueNode } =
10361099 node . type === 'TSEnumMember'
10371100 ? { keyNode : node . id , valueNode : node . initializer }
@@ -1275,6 +1338,21 @@ function defineVisitor({
12751338 setOffset ( atToken , 0 , tokenStore . getFirstToken ( decorators [ 0 ] ) )
12761339 }
12771340 } ,
1341+
1342+ // ----------------------------------------------------------------------
1343+ // DEPRECATED NODES
1344+ // ----------------------------------------------------------------------
1345+ /** @param {any } node */
1346+ TSParenthesizedType ( node ) {
1347+ // Deprecated in @typescript -eslint/parser v5
1348+ // (T)
1349+ processNodeList (
1350+ [ node . typeAnnotation ] ,
1351+ tokenStore . getFirstToken ( node ) ,
1352+ tokenStore . getLastToken ( node ) ,
1353+ 1
1354+ )
1355+ } ,
12781356 // ----------------------------------------------------------------------
12791357 // SINGLE TOKEN NODES
12801358 // ----------------------------------------------------------------------
0 commit comments