Skip to content

Commit 6dff149

Browse files
ingeniumedchriszarate
authored andcommitted
Fix the undefined type problem with api docgen for typescript files
1 parent 609cd09 commit 6dff149

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

packages/docgen/lib/get-export-entries.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ module.exports = ( token ) => {
5454
}
5555

5656
const name = [];
57-
if ( token.declaration === null ) {
57+
if ( ! token.declaration ) {
5858
token.specifiers.forEach( ( specifier ) =>
5959
name.push( {
60-
localName: specifier.local.name,
60+
localName: specifier.local?.name,
6161
exportName: specifier.exported.name,
6262
module: token.source?.value ?? null,
6363
lineStart: specifier.loc.start.line,

packages/docgen/test/get-export-entries.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,4 +502,30 @@ describe( 'Export entries', () => {
502502
} ),
503503
] );
504504
} );
505+
506+
it( 're-exporting node module for external use', () => {
507+
expect(
508+
firstExport(
509+
`
510+
export * as Y from 'yjs';
511+
`,
512+
`
513+
/**
514+
* Exports the entire API of Yjs.
515+
*
516+
* @module yjs
517+
*/
518+
export { Doc, Transaction, YArray as Array, YMap as Map, YText as Text, YXmlText as XmlText, YXmlHook as XmlHook, YXmlElement as XmlElement, YXmlFragment as XmlFragment, YXmlEvent, YMapEvent, YArrayEvent, YTextEvent, YEvent, Item, AbstractStruct, GC, Skip, ContentBinary, ContentDeleted, ContentDoc, ContentEmbed, ContentFormat, ContentJSON, ContentAny, ContentString, ContentType, AbstractType, getTypeChildren, createRelativePositionFromTypeIndex, createRelativePositionFromJSON, createAbsolutePositionFromRelativePosition, compareRelativePositions, AbsolutePosition, RelativePosition, ID, createID, compareIDs, getState, Snapshot, createSnapshot, createDeleteSet, createDeleteSetFromStructStore, cleanupYTextFormatting, snapshot, emptySnapshot, findRootTypeKey, findIndexSS, getItem, getItemCleanStart, getItemCleanEnd, typeListToArraySnapshot, typeMapGetSnapshot, typeMapGetAllSnapshot, createDocFromSnapshot, iterateDeletedStructs, applyUpdate, applyUpdateV2, readUpdate, readUpdateV2, encodeStateAsUpdate, encodeStateAsUpdateV2, encodeStateVector, UndoManager, decodeSnapshot, encodeSnapshot, decodeSnapshotV2, encodeSnapshotV2, decodeStateVector, logUpdate, logUpdateV2, decodeUpdate, decodeUpdateV2, relativePositionToJSON, isDeleted, isParentOf, equalSnapshots, PermanentUserData, tryGc, transact, AbstractConnector, logType, mergeUpdates, mergeUpdatesV2, parseUpdateMeta, parseUpdateMetaV2, encodeStateVectorFromUpdate, encodeStateVectorFromUpdateV2, encodeRelativePosition, decodeRelativePosition, diffUpdate, diffUpdateV2, convertUpdateFormatV1ToV2, convertUpdateFormatV2ToV1, obfuscateUpdate, obfuscateUpdateV2, UpdateEncoderV1, UpdateEncoderV2, UpdateDecoderV1, UpdateDecoderV2, equalDeleteSets, mergeDeleteSets, snapshotContainsUpdate } from "./internals.js";
519+
`
520+
)
521+
).toEqual( [
522+
expect.objectContaining( {
523+
lineStart: 1,
524+
lineEnd: 1,
525+
localName: undefined,
526+
exportName: 'Y',
527+
module: 'yjs',
528+
} ),
529+
] );
530+
} );
505531
} );

0 commit comments

Comments
 (0)