@@ -3161,7 +3161,7 @@ namespace ts {
31613161 return addJSDocComment ( finishNode ( node ) ) ;
31623162 }
31633163
3164- function tryParseParenthesizedArrowFunctionExpression ( ) : Expression {
3164+ function tryParseParenthesizedArrowFunctionExpression ( ) : Expression | undefined {
31653165 const triState = isParenthesizedArrowFunctionExpression ( ) ;
31663166 if ( triState === Tristate . False ) {
31673167 // It's definitely not a parenthesized arrow function expression.
@@ -3324,7 +3324,7 @@ namespace ts {
33243324 return parseParenthesizedArrowFunctionExpressionHead ( /*allowAmbiguity*/ false ) ;
33253325 }
33263326
3327- function tryParseAsyncSimpleArrowFunctionExpression ( ) : ArrowFunction {
3327+ function tryParseAsyncSimpleArrowFunctionExpression ( ) : ArrowFunction | undefined {
33283328 // We do a check here so that we won't be doing unnecessarily call to "lookAhead"
33293329 if ( token ( ) === SyntaxKind . AsyncKeyword ) {
33303330 const isUnParenthesizedAsyncArrowFunction = lookAhead ( isUnParenthesizedAsyncArrowFunctionWorker ) ;
@@ -4398,7 +4398,7 @@ namespace ts {
43984398 return finishNode ( node ) ;
43994399 }
44004400
4401- function tryParseAccessorDeclaration ( fullStart : number , decorators : NodeArray < Decorator > , modifiers : NodeArray < Modifier > ) : AccessorDeclaration {
4401+ function tryParseAccessorDeclaration ( fullStart : number , decorators : NodeArray < Decorator > , modifiers : NodeArray < Modifier > ) : AccessorDeclaration | undefined {
44024402 if ( parseContextualModifier ( SyntaxKind . GetKeyword ) ) {
44034403 return parseAccessorDeclaration ( SyntaxKind . GetAccessor , fullStart , decorators , modifiers ) ;
44044404 }
@@ -4511,7 +4511,7 @@ namespace ts {
45114511 return addJSDocComment ( finishNode ( node ) ) ;
45124512 }
45134513
4514- function parseOptionalIdentifier ( ) {
4514+ function parseOptionalIdentifier ( ) : Identifier | undefined {
45154515 return isIdentifier ( ) ? parseIdentifier ( ) : undefined ;
45164516 }
45174517
@@ -5576,7 +5576,7 @@ namespace ts {
55765576 return addJSDocComment ( finishNode ( node ) ) ;
55775577 }
55785578
5579- function parseNameOfClassDeclarationOrExpression ( ) : Identifier {
5579+ function parseNameOfClassDeclarationOrExpression ( ) : Identifier | undefined {
55805580 // implements is a future reserved word so
55815581 // 'class implements' might mean either
55825582 // - class expression with omitted name, 'implements' starts heritage clause
@@ -6116,7 +6116,7 @@ namespace ts {
61166116 }
61176117
61186118 export namespace JSDocParser {
6119- export function parseJSDocTypeExpressionForTests ( content : string , start : number , length : number ) {
6119+ export function parseJSDocTypeExpressionForTests ( content : string , start : number , length : number ) : { jsDocTypeExpression : JSDocTypeExpression , diagnostics : Diagnostic [ ] } | undefined {
61206120 initializeState ( content , ScriptTarget . Latest , /*_syntaxCursor:*/ undefined , ScriptKind . JS ) ;
61216121 sourceFile = createSourceFile ( "file.js" , ScriptTarget . Latest , ScriptKind . JS ) ;
61226122 scanner . setText ( content , start , length ) ;
@@ -6141,7 +6141,7 @@ namespace ts {
61416141 return finishNode ( result ) ;
61426142 }
61436143
6144- export function parseIsolatedJSDocComment ( content : string , start : number , length : number ) {
6144+ export function parseIsolatedJSDocComment ( content : string , start : number , length : number ) : { jsDoc : JSDoc , diagnostics : Diagnostic [ ] } | undefined {
61456145 initializeState ( content , ScriptTarget . Latest , /*_syntaxCursor:*/ undefined , ScriptKind . JS ) ;
61466146 sourceFile = < SourceFile > { languageVariant : LanguageVariant . Standard , text : content } ;
61476147 const jsDoc = parseJSDocCommentWorker ( start , length ) ;
@@ -6476,7 +6476,7 @@ namespace ts {
64766476 tags . end = tag . end ;
64776477 }
64786478
6479- function tryParseTypeExpression ( ) : JSDocTypeExpression {
6479+ function tryParseTypeExpression ( ) : JSDocTypeExpression | undefined {
64806480 return tryParse ( ( ) => {
64816481 skipWhitespace ( ) ;
64826482 if ( token ( ) !== SyntaxKind . OpenBraceToken ) {
@@ -6767,7 +6767,7 @@ namespace ts {
67676767 return false ;
67686768 }
67696769
6770- function parseTemplateTag ( atToken : AtToken , tagName : Identifier ) : JSDocTemplateTag {
6770+ function parseTemplateTag ( atToken : AtToken , tagName : Identifier ) : JSDocTemplateTag | undefined {
67716771 if ( forEach ( tags , t => t . kind === SyntaxKind . JSDocTemplateTag ) ) {
67726772 parseErrorAtPosition ( tagName . pos , scanner . getTokenPos ( ) - tagName . pos , Diagnostics . _0_tag_already_specified , tagName . escapedText ) ;
67736773 }
@@ -6829,12 +6829,10 @@ namespace ts {
68296829 return entity ;
68306830 }
68316831
6832- function parseJSDocIdentifierName ( createIfMissing = false ) : Identifier {
6833- return createJSDocIdentifier ( tokenIsIdentifierOrKeyword ( token ( ) ) , createIfMissing ) ;
6834- }
6835-
6836- function createJSDocIdentifier ( isIdentifier : boolean , createIfMissing : boolean ) : Identifier {
6837- if ( ! isIdentifier ) {
6832+ function parseJSDocIdentifierName ( ) : Identifier | undefined ;
6833+ function parseJSDocIdentifierName ( createIfMissing : true ) : Identifier ;
6834+ function parseJSDocIdentifierName ( createIfMissing = false ) : Identifier | undefined {
6835+ if ( ! tokenIsIdentifierOrKeyword ( token ( ) ) ) {
68386836 if ( createIfMissing ) {
68396837 return createMissingNode < Identifier > ( SyntaxKind . Identifier , /*reportAtCurrentPosition*/ true , Diagnostics . Identifier_expected ) ;
68406838 }
@@ -7215,7 +7213,7 @@ namespace ts {
72157213 }
72167214 }
72177215
7218- function getLastChildWorker ( node : Node ) : Node {
7216+ function getLastChildWorker ( node : Node ) : Node | undefined {
72197217 let last : Node = undefined ;
72207218 forEachChild ( node , child => {
72217219 if ( nodeIsPresent ( child ) ) {
0 commit comments