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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ exports[`language-typescript DEFAULT_DOCUMENTATION_GENERATOR without a descripti
*/"
`;

exports[`language-typescript DEFAULT_DOCUMENTATION_GENERATOR with default values with 1 default value as an object 1`] = `
"
/**
* @default {"number":1,"string":"string"}
*/"
`;

exports[`language-typescript DEFAULT_DOCUMENTATION_GENERATOR without a description without tags 1`] = `""`;

exports[`language-typescript DEFAULT_ENUM_FORMATTER w/ deprecated value 1`] = `
Expand Down
9 changes: 9 additions & 0 deletions packages/language-typescript/src/__tests__/index-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,14 @@ describe('language-typescript', () => {
})).toMatchSnapshot();
});
});

describe('with default values', () => {
it('with default value as an object', () => {
expect(DEFAULT_DOCUMENTATION_GENERATOR({
description: 'This is a thing',
tags: [{tag: 'default', value: JSON.stringify({number: 1, string: "string"})}]
})).toMatchSnapshot();
});
});
});
});
2 changes: 1 addition & 1 deletion packages/language-typescript/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const fixDescriptionDocblock: (description?: string) => string | undefined = des

export const DEFAULT_DOCUMENTATION_GENERATOR: GenerateDocumentation = ({ description, tags = [] }) => (description || tags.length) ? `
/**
* ${filterAndJoinArray([fixDescriptionDocblock(description), ...tags.map(({ tag, value }) => `@${tag} ${value}`)], '\n* ')}
* ${filterAndJoinArray([fixDescriptionDocblock(description), ...tags.map(({ tag, value }) => `@${tag} ${typeof value === 'object' ? JSON.stringify(value) : value}`)], '\n* ')}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should just JSON.stringify everything, so then strings will be quoted

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've add object check for it. But i don't know how fix snapshot.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what I meant was that I think we should just JSON.stringify instead of having the typecheck.

you should be able to fix the snapshot by running npm test -- -u

*/` : '';

export const DEFAULT_OPTIONS: IFromQueryOptions = {
Expand Down