This repository was archived by the owner on Jan 19, 2019. It is now read-only.
File tree 1 file changed +8
-19
lines changed
1 file changed +8
-19
lines changed Original file line number Diff line number Diff line change @@ -250,26 +250,9 @@ function isComma(token) {
250
250
* @returns {boolean } is commment
251
251
*/
252
252
function isComment ( token ) {
253
- return ( token . kind === SyntaxKind . SingleLineCommentTrivia || token . kind === SyntaxKind . MultiLineCommentTrivia ) || ( token . kind >= SyntaxKind . JSDocTypeExpression && token . kind <= SyntaxKind . JSDocTypeLiteral ) ;
253
+ return token . kind === SyntaxKind . SingleLineCommentTrivia || token . kind === SyntaxKind . MultiLineCommentTrivia || ( token . kind >= SyntaxKind . JSDocTypeExpression && token . kind <= SyntaxKind . JSDocTypeLiteral ) ;
254
254
}
255
255
256
- /**
257
- * Returns true if the given TSToken is inside a comment
258
- * Non-comment type tokens are generated for types in JSDoc Blocks
259
- * @param {TSToken } token the TypeScript token
260
- * @returns {boolean } is inside a commment
261
- */
262
- function isInsideComment ( token ) {
263
- if ( token . kind === SyntaxKind . SourceFile ) {
264
- return false ;
265
- }
266
- if ( isComment ( token ) ) {
267
- return true ;
268
- }
269
- return isInsideComment ( token . parent ) ;
270
- }
271
-
272
-
273
256
/**
274
257
* Returns the binary expression type of the given TSToken
275
258
* @param {TSToken } operator the operator token
@@ -719,7 +702,13 @@ function convertTokens(ast) {
719
702
* @returns {undefined }
720
703
*/
721
704
function walk ( node ) {
722
- if ( isToken ( node ) && ! isInsideComment ( node ) && node . kind !== SyntaxKind . EndOfFileToken ) {
705
+ // TypeScript generates tokens for types in JSDoc blocks. Comment tokens
706
+ // and their children should not be walked or added to the resulting tokens list.
707
+ if ( isComment ( node ) ) {
708
+ return ;
709
+ }
710
+
711
+ if ( isToken ( node ) && node . kind !== SyntaxKind . EndOfFileToken ) {
723
712
const converted = convertToken ( node , ast ) ;
724
713
725
714
if ( converted ) {
You can’t perform that action at this time.
0 commit comments