@@ -43,7 +43,7 @@ export default class DocElementParser {
4343
4444 const markupElements : MarkupBasicElement [ ] = [ ] ;
4545 let parsing : boolean = true ;
46- let token : Token ;
46+ let token : Token | undefined ;
4747
4848 while ( parsing ) {
4949 token = tokenizer . peekToken ( ) ;
@@ -66,7 +66,7 @@ export default class DocElementParser {
6666 documentation . isDocInherited = true ;
6767 break ;
6868 case '@link' :
69- const linkMarkupElement : MarkupElement = this . parseLinkTag ( documentation , token ) ;
69+ const linkMarkupElement : MarkupElement | undefined = this . parseLinkTag ( documentation , token ) ;
7070 if ( linkMarkupElement ) {
7171 // Push to linkMarkupElement to retain position in the documentation
7272 markupElements . push ( linkMarkupElement ) ;
@@ -101,7 +101,7 @@ export default class DocElementParser {
101101 /**
102102 * This method parses the semantic information in an \@link JSDoc tag, creates and returns a
103103 * MarkupElement with the corresponding information. If the corresponding inline tag \@link is
104- * not formatted correctly an error will be reported.
104+ * not formatted correctly an error will be reported and undefined is returned .
105105 *
106106 * The format for the \@link tag is {\@link URL or API defintion reference | display text}, where
107107 * the '|' is only needed if the optional display text is given.
@@ -112,18 +112,17 @@ export default class DocElementParser {
112112 * \{@link @microsoft/sp-core-library:Guid.newGuid | new Guid Object \ }
113113 * \{@link @microsoft/sp-core-library:Guid.newGuid \ }
114114 */
115- public static parseLinkTag ( documentation : ApiDocumentation , tokenItem : Token ) : MarkupBasicElement {
115+ public static parseLinkTag ( documentation : ApiDocumentation , tokenItem : Token ) : MarkupBasicElement | undefined {
116116 if ( ! tokenItem . text ) {
117117 documentation . reportError ( 'The {@link} tag must include a URL or API item reference' ) ;
118- return ;
118+ return undefined ;
119119 }
120120
121121 // Make sure there are no extra pipes
122122 const pipeSplitContent : string [ ] = tokenItem . text . split ( '|' ) . map ( value => {
123- if ( value ) {
124- return value . trim ( ) ;
125- }
123+ return value ? value . trim ( ) : value ;
126124 } ) ;
125+
127126 if ( pipeSplitContent . length > 2 ) {
128127 documentation . reportError ( 'The {@link} tag contains more than one pipe character ("|")' ) ;
129128 return undefined ;
@@ -136,7 +135,7 @@ export default class DocElementParser {
136135
137136 // If a display name is given, ensure it only contains characters for words.
138137 if ( displayTextPart ) {
139- const match : RegExpExecArray | undefined = this . _displayTextBadCharacterRegEx . exec ( displayTextPart ) ;
138+ const match : RegExpExecArray | null = this . _displayTextBadCharacterRegEx . exec ( displayTextPart ) ;
140139 if ( match ) {
141140 documentation . reportError ( `The {@link} tag\'s display text contains an unsupported`
142141 + ` character: "${ match [ 0 ] } "` ) ;
@@ -162,7 +161,7 @@ export default class DocElementParser {
162161 linkMarkupElement = Markup . createWebLink ( displayTextElements , addressPart ) ;
163162 } else {
164163 // we are processing an API definition reference
165- const apiDefitionRef : ApiDefinitionReference = ApiDefinitionReference . createFromString (
164+ const apiDefitionRef : ApiDefinitionReference | undefined = ApiDefinitionReference . createFromString (
166165 addressPart ,
167166 documentation . reportError
168167 ) ;
@@ -212,7 +211,7 @@ export default class DocElementParser {
212211
213212 // Create the IApiDefinitionReference object
214213 // Deconstruct the API reference expression 'scopeName/packageName:exportName.memberName'
215- const apiDefinitionRef : ApiDefinitionReference = ApiDefinitionReference . createFromString (
214+ const apiDefinitionRef : ApiDefinitionReference | undefined = ApiDefinitionReference . createFromString (
216215 token . text ,
217216 documentation . reportError
218217 ) ;
@@ -223,7 +222,7 @@ export default class DocElementParser {
223222 }
224223
225224 // Atempt to locate the apiDefinitionRef
226- const resolvedAstItem : ResolvedApiItem = documentation . referenceResolver . resolve (
225+ const resolvedAstItem : ResolvedApiItem | undefined = documentation . referenceResolver . resolve (
227226 apiDefinitionRef ,
228227 documentation . context . package ,
229228 warnings
@@ -254,20 +253,20 @@ export default class DocElementParser {
254253 // Add additional cases if needed
255254 switch ( resolvedAstItem . kind ) {
256255 case AstItemKind . Function :
257- documentation . parameters = resolvedAstItem . params ;
258- documentation . returnsMessage = resolvedAstItem . returnsMessage ;
256+ documentation . parameters = resolvedAstItem . params || { } ;
257+ documentation . returnsMessage = resolvedAstItem . returnsMessage || [ ] ;
259258 break ;
260259 case AstItemKind . Method :
261260 case AstItemKind . Constructor :
262- documentation . parameters = resolvedAstItem . params ;
263- documentation . returnsMessage = resolvedAstItem . returnsMessage ;
261+ documentation . parameters = resolvedAstItem . params || { } ;
262+ documentation . returnsMessage = resolvedAstItem . returnsMessage || [ ] ;
264263 break ;
265264 }
266265
267266 // Check if inheritdoc is depreacted
268267 // We need to check if this documentation has a deprecated message
269268 // but it may not appear until after this token.
270- if ( resolvedAstItem . deprecatedMessage . length > 0 ) {
269+ if ( resolvedAstItem . deprecatedMessage && resolvedAstItem . deprecatedMessage . length > 0 ) {
271270 documentation . isDocInheritedDeprecated = true ;
272271 }
273272 }
0 commit comments