Skip to content

Commit 2dcfa87

Browse files
authored
fix: JSDoc generation (#92)
1 parent 086519e commit 2dcfa87

File tree

4 files changed

+26
-26
lines changed

4 files changed

+26
-26
lines changed

plugins/typescript/src/core/schemaToTypeAliasDeclaration.test.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ describe("schemaToTypeAliasDeclaration", () => {
101101
* Cron timing schema for create requests.
102102
*/
103103
export type Test = {
104-
/*
104+
/**
105105
* The string representing the timing's cron expression.
106106
*
107107
* @format cron-string
@@ -202,13 +202,13 @@ describe("schemaToTypeAliasDeclaration", () => {
202202
* An object
203203
*/
204204
export type Test = {
205-
/*
205+
/**
206206
* I’m a foo
207207
*
208208
* @default boom
209209
*/
210210
foo: string;
211-
/*
211+
/**
212212
* @minimum 0
213213
* @maximum 42
214214
*/
@@ -273,19 +273,19 @@ describe("schemaToTypeAliasDeclaration", () => {
273273
* An object
274274
*/
275275
export type Test = {
276-
/*
276+
/**
277277
* I’m a foo
278278
*
279279
* @default boom
280280
*/
281281
foo: {
282-
/*
282+
/**
283283
* @minimum 0
284284
* @maximum 42
285285
*/
286286
bar?: number;
287287
baz?: {
288-
/*
288+
/**
289289
* @default yeah
290290
*/
291291
oh?: string;
@@ -690,7 +690,7 @@ describe("schemaToTypeAliasDeclaration", () => {
690690
* A nice top-level description
691691
*/
692692
export type Test = {
693-
/*
693+
/**
694694
* A nice description for foo
695695
*/
696696
foo?: string;
@@ -793,66 +793,66 @@ describe("schemaToTypeAliasDeclaration", () => {
793793

794794
expect(printSchema(schema)).toMatchInlineSnapshot(`
795795
"export type Test = {
796-
/*
796+
/**
797797
* Description of the gist
798798
*
799799
* @example Example Ruby script
800800
*/
801801
description: string;
802-
/*
802+
/**
803803
* Names of files to be updated
804804
*
805805
* @example {\\"hello.rb\\":{\\"content\\":\\"blah\\",\\"filename\\":\\"goodbye.rb\\"}}
806806
*/
807807
files?: {
808808
[key: string]: {
809-
/*
809+
/**
810810
* The new content of the file
811811
*/
812812
content: string;
813-
/*
813+
/**
814814
* The new filename for the file
815815
*/
816816
filename?: string | null;
817817
} | {
818-
/*
818+
/**
819819
* The new content of the file
820820
*/
821821
content?: string;
822-
/*
822+
/**
823823
* The new filename for the file
824824
*/
825825
filename: string | null;
826826
} | {} | null;
827827
};
828828
} | {
829-
/*
829+
/**
830830
* Description of the gist
831831
*
832832
* @example Example Ruby script
833833
*/
834834
description?: string;
835-
/*
835+
/**
836836
* Names of files to be updated
837837
*
838838
* @example {\\"hello.rb\\":{\\"content\\":\\"blah\\",\\"filename\\":\\"goodbye.rb\\"}}
839839
*/
840840
files: {
841841
[key: string]: {
842-
/*
842+
/**
843843
* The new content of the file
844844
*/
845845
content: string;
846-
/*
846+
/**
847847
* The new filename for the file
848848
*/
849849
filename?: string | null;
850850
} | {
851-
/*
851+
/**
852852
* The new content of the file
853853
*/
854854
content?: string;
855-
/*
855+
/**
856856
* The new filename for the file
857857
*/
858858
filename: string | null;

plugins/typescript/src/core/schemaToTypeAliasDeclaration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ const addJSDocToNode = (node: ts.Node, jsDocComment: ts.JSDoc) => {
638638
ts.addSyntheticLeadingComment(
639639
node,
640640
ts.SyntaxKind.MultiLineCommentTrivia,
641-
jsDocString,
641+
"*" + jsDocString, // https://github.com/microsoft/TypeScript/issues/17146
642642
true
643643
);
644644
};

plugins/typescript/src/generators/generateReactQueryComponents.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,11 @@ describe("generateReactQueryComponents", () => {
205205
import type * as Schemas from \\"./petstoreSchemas\\";
206206
207207
export type ListPetsQueryParams = {
208-
/*
208+
/**
209209
* Filter on the dog breed
210210
*/
211211
breed: string;
212-
/*
212+
/**
213213
* Color of the dog
214214
*/
215215
color?: \\"white\\" | \\"black\\" | \\"grey\\";
@@ -327,14 +327,14 @@ describe("generateReactQueryComponents", () => {
327327
import type * as Schemas from \\"./petstoreSchemas\\";
328328
329329
export type ListPetsQueryParams = {
330-
/*
330+
/**
331331
* Color of the dog
332332
*/
333333
color?: \\"white\\" | \\"black\\" | \\"grey\\";
334334
};
335335
336336
export type ListPetsHeaders = {
337-
/*
337+
/**
338338
* Filter on the dog breed
339339
*/
340340
breed?: string;

plugins/typescript/src/generators/generateSchemaTypes.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ describe("generateSchemaTypes", () => {
142142
* A new pet.
143143
*/
144144
export type Pet = NewPet & {
145-
/*
145+
/**
146146
* @format int64
147147
*/
148148
id: number;
@@ -185,7 +185,7 @@ describe("generateSchemaTypes", () => {
185185
* An error :(
186186
*/
187187
export type Error = {
188-
/*
188+
/**
189189
* @format int32
190190
*/
191191
code: number;

0 commit comments

Comments
 (0)