This repository was archived by the owner on Oct 16, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import {
20
20
} from '@typescript-eslint/experimental-utils' ;
21
21
import { isReassignmentTarget } from 'tsutils' ;
22
22
import * as ts from 'typescript' ;
23
+ import { stringifyJSDocTagInfoText } from '../utils/stringifyJSDocTagInfoText' ;
23
24
24
25
const createRule = ESLintUtils . RuleCreator (
25
26
( ) => 'https://github.com/gund/eslint-plugin-deprecation' ,
@@ -288,7 +289,7 @@ function isCallExpression(
288
289
function getJsDocDeprecation ( tags : ts . JSDocTagInfo [ ] ) {
289
290
for ( const tag of tags ) {
290
291
if ( tag . name === 'deprecated' ) {
291
- return { reason : tag . text || '' } ;
292
+ return { reason : stringifyJSDocTagInfoText ( tag ) } ;
292
293
}
293
294
}
294
295
return undefined ;
Original file line number Diff line number Diff line change
1
+ import * as ts from 'typescript' ;
2
+
3
+ /**
4
+ * Stringifies the text within a JSDocTagInfo AST node with compatibility for
5
+ * pre/post TypeScript 4.3 API changes.
6
+ */
7
+ export function stringifyJSDocTagInfoText ( tag : ts . JSDocTagInfo ) : string {
8
+ return isJSDocTagInfo4Point2AndBefore ( tag )
9
+ ? tag . text ?? ''
10
+ : ts . displayPartsToString ( tag . text ) ;
11
+ }
12
+
13
+ /**
14
+ * Copied from TypeScript 4.2.
15
+ * https://github.com/microsoft/TypeScript/blob/fb6c8392681f50a305236a7d662123a69827061f/lib/protocol.d.ts#L2820-L2823
16
+ *
17
+ * The `text` field was changed from `string` to `SymbolDisplayPart[]` in 4.3.
18
+ */
19
+ interface JSDocTagInfo4Point2AndBefore {
20
+ name : string ;
21
+ text ?: string ;
22
+ }
23
+
24
+ function isJSDocTagInfo4Point2AndBefore (
25
+ tag : ts . JSDocTagInfo | JSDocTagInfo4Point2AndBefore ,
26
+ ) : tag is JSDocTagInfo4Point2AndBefore {
27
+ return typeof tag . text === 'string' ;
28
+ }
You can’t perform that action at this time.
0 commit comments