@@ -11,7 +11,12 @@ import {
1111import { printDanglingComments } from "../../main/comments/print.js" ;
1212import hasNewline from "../../utilities/has-newline.js" ;
1313import { locEnd } from "../location/index.js" ;
14- import { CommentCheckFlags , hasComment } from "../utilities/comments.js" ;
14+ import { isLineComment } from "../utilities/comment-types.js" ;
15+ import {
16+ CommentCheckFlags ,
17+ getComments ,
18+ hasComment ,
19+ } from "../utilities/comments.js" ;
1520import { getFunctionParameters } from "../utilities/function-parameters.js" ;
1621import { isObjectType } from "../utilities/node-types.js" ;
1722import { isTestCall } from "../utilities/test-libraries.js" ;
@@ -83,15 +88,19 @@ function printTypeParameters(path, options, print, paramsKey) {
8388 ( parameters . length === 1 &&
8489 ( parameters [ 0 ] . type === "NullableTypeAnnotation" ||
8590 shouldHugType ( parameters [ 0 ] ) ) ) ) &&
86- ! parameters . some (
87- ( node ) =>
88- hasComment ( node , CommentCheckFlags . Line ) ||
89- // This condition base on existing one in class-body.js
90- // It is not really correct, but we don't have a way to check how comments are printed
91- hasComment ( node , CommentCheckFlags . Last , ( comment ) =>
92- hasNewline ( options . originalText , locEnd ( comment ) ) ,
93- ) ,
94- ) ) ;
91+ ! parameters . some ( ( node ) => {
92+ const comments = getComments (
93+ node ,
94+ ( comment ) => comment . leading || comment . trailing ,
95+ ) ;
96+ return (
97+ comments . length > 0 &&
98+ ( comments . some ( ( comment ) => isLineComment ( comment ) ) ||
99+ // This condition base on existing one in class-body.js
100+ // It is not really correct, but we don't have a way to check how comments are printed
101+ hasNewline ( options . originalText , locEnd ( comments . at ( - 1 ) ) ) )
102+ ) ;
103+ } ) ) ;
95104
96105 if ( shouldInline ) {
97106 return [
0 commit comments