Skip to content

Commit aef14ff

Browse files
committed
Use jsdoc-style comments for all descriptions. No single line comments for descriptions
1 parent 09cdeca commit aef14ff

File tree

6 files changed

+17
-16
lines changed

6 files changed

+17
-16
lines changed

src/TsTypes.ts

+5-8
Original file line numberDiff line numberDiff line change
@@ -201,16 +201,13 @@ export namespace TsType {
201201
if (settings.endPropertyWithSemicolon)
202202
decl += ';'
203203
204-
//Single line description in comment to the right of declaration
205-
//Multiple line description in comment above
204+
//All descriptions will be inside jsdoc-style comments to support hinting in editors
205+
//(ie intellisense)
206206
if (settings.propertyDescription && _.type.description && !_.type.id)
207-
decl = newLineRegex.test(_.type.description) ?
208-
_.type.description
207+
decl = _.type.description
209208
.split(newLineRegex)
210-
.map((line, lineNum) => indentString + (lineNum > 0 ? multiLineCommentIndent : multiLineCommentStart) + line)
211-
.join('\n') +
212-
'\n' + indentString + multiLineCommentEnd + '\n' + decl :
213-
decl + ' // ' + _.type.description
209+
.map((line, lineNum, lines) => (lineNum > 0 ? multiLineCommentIndent : indentString + multiLineCommentStart) + line)
210+
.join('\n' + indentString) + multiLineCommentEnd + '\n' + decl
214211
215212
return decl
216213
}).join('\n')}

test/cases/basics.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ export var configurations = [
3434
types: `export interface ExampleSchema {
3535
firstName: string;
3636
lastName: string;
37-
age?: number; // Age in years
37+
/** Age in years */
38+
age?: number;
3839
height?: number;
3940
favoriteFoods?: any[];
4041
likesDogs?: boolean;

test/cases/not-extendable.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@ export var schema = {
2121
export var types = `export interface ExampleSchema {
2222
firstName: string;
2323
lastName: string;
24-
age?: number; // Age in years
24+
/** Age in years */
25+
age?: number;
2526
}`

test/cases/ref.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ export var configurations = [
1919
types: `export interface ExampleSchema {
2020
firstName: string;
2121
lastName: string;
22-
age?: number; // Age in years
22+
/** Age in years */
23+
age?: number;
2324
height?: number;
2425
favoriteFoods?: any[];
2526
likesDogs?: boolean;
@@ -37,4 +38,4 @@ export interface Referencing {
3738
foo: ExampleSchema;
3839
}`
3940
}
40-
]
41+
]

test/cases/with-description-newlines.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ export var schema = {
2121

2222
export var types = `/** My cool schema */
2323
export interface ExampleSchema {
24-
firstName: string; // first name single line description
24+
/** first name single line description */
25+
firstName: string;
2526
lastName: string;
2627
/** Age description with
27-
* multiple lines
28-
*/
28+
* multiple lines */
2929
age?: number;
3030
[k: string]: any;
3131
}`

test/cases/with-description.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export var types = `/** My cool schema */
2222
export interface ExampleSchema {
2323
firstName: string;
2424
lastName: string;
25-
age?: number; // Age in years
25+
/** Age in years */
26+
age?: number;
2627
[k: string]: any;
2728
}`

0 commit comments

Comments
 (0)