Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/api/src/SymbolParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,7 @@ export class SymbolParser implements ISymbolParser {
} else if (ts.isObjectBindingPattern(node)) {
addProperties(node.elements);
} else if (ts.isObjectLiteralExpression(node)) {
prop.kind = PropKind.Object;
addProperties(node.properties);
} else if (ts.isIdentifier(node)) {
if (
Expand Down Expand Up @@ -886,6 +887,11 @@ export class SymbolParser implements ISymbolParser {
node.elements,
options,
);
} else if (
ts.isIdentifier(node) &&
node.originalKeywordKind === ts.SyntaxKind.UndefinedKeyword
) {
prop.kind = PropKind.Undefined;
} else {
switch (node.kind) {
case ts.SyntaxKind.NumberKeyword:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ describe('docs-document', () => {
expect(result).toMatchObject({
default: {
type: 'Document',
kind: 15,
kind: 26,
properties: [
{
name: 'name',
Expand Down
48 changes: 48 additions & 0 deletions packages/api/test/typescript/array/array-prop.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,52 @@ describe('array', () => {
},
});
});
it('holey array', () => {
const results = parseFiles([path.resolve(__dirname, 'holey-array.ts')]);
expect(results).toEqual({
HoleyArray: {
kind: 16,
value: [
{
kind: 8,
},
{
kind: 2,
value: 1,
},
{
kind: 8,
},
],
name: 'HoleyArray',
type: 'Array',
description: 'create a new array with holes in it',
},
});
});
it('array with empty objects', () => {
const results = parseFiles([
path.resolve(__dirname, 'array-with-empty-objects.ts'),
]);
expect(results).toEqual({
empty: {
kind: 16,
value: [
{
kind: 26,
},
{
kind: 26,
},
{
kind: 2,
value: 0,
},
],
name: 'empty',
type: 'Array',
description: 'an array with emptys',
},
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* an array with emptys
*/
export const empty = [{}, {}, 0];
4 changes: 4 additions & 0 deletions packages/api/test/typescript/array/holey-array.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* create a new array with holes in it
*/
export const HoleyArray = [undefined, 1, undefined];
4 changes: 2 additions & 2 deletions packages/api/test/typescript/interface/interface-prop.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('interface', () => {
expect(results).toEqual({
default: {
name: 'default',
kind: 14,
kind: 26,
type: 'Person',
properties: [
{
Expand Down Expand Up @@ -46,7 +46,7 @@ describe('interface', () => {
expect(results).toEqual({
default: {
name: 'Person',
kind: 14,
kind: 26,
properties: [
{
name: 'title',
Expand Down
4 changes: 2 additions & 2 deletions packages/api/test/typescript/object/object-prop.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ describe('object', () => {
},
],
type: 'Site',
kind: 15,
kind: 26,
},
{
name: 'facebook',
Expand All @@ -165,7 +165,7 @@ describe('object', () => {
},
],
type: 'Site',
kind: 15,
kind: 26,
},
],
kind: 26,
Expand Down
2 changes: 1 addition & 1 deletion packages/api/test/typescript/type/type-prop.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ describe('type', () => {
expect(results).toEqual({
obj: {
description: 'this is an object',
kind: 15,
kind: 26,
properties: [
{
description: 'field a',
Expand Down