@@ -163,7 +163,7 @@ function maybeHideConstructor(
163
163
return ts . createConstructor (
164
164
node . decorators ,
165
165
[ modifier ] ,
166
- /*parameters=*/ [ ] ,
166
+ /*parameters=*/ [ ] ,
167
167
/* body= */ undefined
168
168
) ;
169
169
} else {
@@ -340,8 +340,8 @@ function extractJSDocComment(
340
340
}
341
341
} ) ;
342
342
343
- if ( comments . length > 0 ) {
344
- const jsDocTags = ts . getJSDocTags ( symbol . declarations ! [ overloadCount ] ) ;
343
+ if ( comments . length > 0 && symbol . declarations ) {
344
+ const jsDocTags = ts . getJSDocTags ( symbol . declarations [ overloadCount ] ) ;
345
345
const maybeNewline = jsDocTags ?. length > 0 ? '\n' : '' ;
346
346
const joinedComments = comments
347
347
. map ( comment => {
@@ -412,19 +412,21 @@ function extractExportedSymbol(
412
412
// See if there is an exported symbol that extends this private symbol.
413
413
// In this case, we can safely use the public symbol instead.
414
414
for ( const symbol of allExportedSymbols ) {
415
- for ( const declaration of symbol . declarations ! ) {
416
- if (
417
- ts . isClassDeclaration ( declaration ) ||
418
- ts . isInterfaceDeclaration ( declaration )
419
- ) {
420
- for ( const heritageClause of declaration . heritageClauses || [ ] ) {
421
- for ( const type of heritageClause . types || [ ] ) {
422
- if ( ts . isIdentifier ( type . expression ) ) {
423
- const subclassName = type . expression . escapedText ;
424
- if ( subclassName === localSymbolName ) {
425
- // TODO: We may need to change this to return a Union type if
426
- // more than one public type corresponds to the private type.
427
- return symbol ;
415
+ if ( symbol . declarations ) {
416
+ for ( const declaration of symbol . declarations ) {
417
+ if (
418
+ ts . isClassDeclaration ( declaration ) ||
419
+ ts . isInterfaceDeclaration ( declaration )
420
+ ) {
421
+ for ( const heritageClause of declaration . heritageClauses || [ ] ) {
422
+ for ( const type of heritageClause . types || [ ] ) {
423
+ if ( ts . isIdentifier ( type . expression ) ) {
424
+ const subclassName = type . expression . escapedText ;
425
+ if ( subclassName === localSymbolName ) {
426
+ // TODO: We may need to change this to return a Union type if
427
+ // more than one public type corresponds to the private type.
428
+ return symbol ;
429
+ }
428
430
}
429
431
}
430
432
}
@@ -438,8 +440,8 @@ function extractExportedSymbol(
438
440
// symbol. Note that this is not always safe as we might replace the local
439
441
// symbol with a less restrictive type.
440
442
const localSymbol = typeChecker . getSymbolAtLocation ( typeName ) ;
441
- if ( localSymbol ) {
442
- for ( const declaration of localSymbol ! . declarations ! ) {
443
+ if ( localSymbol ?. declarations ) {
444
+ for ( const declaration of localSymbol . declarations ) {
443
445
if (
444
446
ts . isClassDeclaration ( declaration ) ||
445
447
ts . isInterfaceDeclaration ( declaration )
@@ -517,10 +519,10 @@ function dropPrivateApiTransformer(
517
519
) ;
518
520
return publicName
519
521
? factory . updateTypeReferenceNode (
520
- node ,
521
- factory . createIdentifier ( publicName . name ) ,
522
- node . typeArguments
523
- )
522
+ node ,
523
+ factory . createIdentifier ( publicName . name ) ,
524
+ node . typeArguments
525
+ )
524
526
: node ;
525
527
}
526
528
0 commit comments