Skip to content

Commit 7cd51e2

Browse files
authored
fix(javascript): keep comments and jsdoc in build (#307)
1 parent 7a65dac commit 7cd51e2

File tree

6 files changed

+122
-125
lines changed

6 files changed

+122
-125
lines changed

clients/algoliasearch-client-javascript/bundlesize.config.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@
3838
},
3939
{
4040
"path": "packages/client-common/dist/client-common.esm.node.js",
41-
"maxSize": "3.80KB"
41+
"maxSize": "5.25KB"
4242
},
4343
{
4444
"path": "packages/requester-browser-xhr/dist/requester-browser-xhr.esm.node.js",
45-
"maxSize": "825B"
45+
"maxSize": "900B"
4646
},
4747
{
4848
"path": "packages/requester-node-http/dist/requester-node-http.esm.node.js",
49-
"maxSize": "1.10KB"
49+
"maxSize": "1.15KB"
5050
}
5151
]
5252
}

clients/algoliasearch-client-javascript/rollup.config.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ packagesConfig.forEach((packageConfig) => {
183183

184184
packageConfig.formats.forEach((format) => {
185185
// Avoid generating types multiple times.
186-
let isTypesGenerated = false;
186+
let areTypesGenerated = false;
187187
const output = bundlers[format];
188188
const isUmdBuild = format === 'umd-browser';
189189
const isEsmBrowserBuild = format === 'esm-browser';
@@ -244,12 +244,12 @@ packagesConfig.forEach((packageConfig) => {
244244
}),
245245
nodeResolve(),
246246
ts({
247-
check: !isTypesGenerated,
247+
check: !areTypesGenerated,
248248
tsconfig: path.resolve(clientPath, 'tsconfig.json'),
249249
tsconfigOverride: {
250250
compilerOptions: {
251-
declaration: !isTypesGenerated,
252-
declarationMap: !isTypesGenerated,
251+
declaration: !areTypesGenerated,
252+
declarationMap: !areTypesGenerated,
253253
},
254254
},
255255
}),
@@ -269,7 +269,7 @@ packagesConfig.forEach((packageConfig) => {
269269
},
270270
});
271271

272-
isTypesGenerated = true;
272+
areTypesGenerated = true;
273273
});
274274
});
275275

clients/algoliasearch-client-javascript/tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
"lib": ["dom", "esnext", "dom.iterable", "scripthost"],
88
"module": "esnext",
99
"moduleResolution": "node",
10-
"noImplicitAny": false,
10+
"noImplicitAny": true,
1111
"noImplicitThis": true,
1212
"noLib": false,
1313
"noUnusedLocals": true,
1414
"outDir": "dist",
15-
"removeComments": true,
15+
"removeComments": false,
1616
"sourceMap": true,
1717
"strict": true,
1818
"suppressImplicitAnyIndexErrors": true,

templates/javascript/api-all.mustache

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import type { Region } from '../src/{{apiName}}Api';
1212

1313
export * from '../src/{{apiName}}Api';
1414

15-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
1615
export function {{apiName}}Api(
1716
appId: string,
1817
apiKey: string,{{#hasRegionalHost}}region{{#fallbackToAliasHost}}?{{/fallbackToAliasHost}}: Region,{{/hasRegionalHost}}

templates/javascript/api-single.mustache

Lines changed: 112 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -108,150 +108,151 @@ export function create{{capitalizedApiName}}Api(options: CreateClientOptions{{#h
108108
transporter.userAgent.add({ segment, version });
109109
}
110110

111-
{{#operation}}
112-
/**
113-
{{#notes}}
114-
* {{&notes}}
115-
{{/notes}}
116-
{{#summary}}
117-
* @summary {{&summary}}
118-
{{/summary}}
119-
{{#allParams.0}}
120-
{{^bodyParams.0}}
121-
* @param {{nickname}} - The {{nickname}} object.
122-
{{#allParams}}
123-
* @param {{nickname}}.{{paramName}} {{^description}}The {{paramName}} object.{{/description}}{{#description}}{{{description}}}{{/description}}
124-
{{/allParams}}
125-
{{/bodyParams.0}}
126-
{{#bodyParams.0}}
127-
{{^queryParams.0}}
128-
{{^pathParams.0}}
129-
{{#bodyParams.0.isArray}}
130-
{{^bodyParams.1}}
131-
* @param {{nickname}} - The {{nickname}} object.
132-
{{#allParams}}
133-
* @param {{nickname}}.{{paramName}} {{^description}}The {{paramName}} object.{{/description}}{{#description}}{{{description}}}{{/description}}
134-
{{/allParams}}
135-
{{/bodyParams.1}}
136-
{{/bodyParams.0.isArray}}
137-
{{^bodyParams.0.isArray}}
138-
* @param {{paramName}} {{^description}}The {{paramName}} object.{{/description}}{{#description}}{{{description}}}{{/description}}
139-
{{/bodyParams.0.isArray}}
140-
{{/pathParams.0}}
141-
{{#pathParams.0}}
142-
* @param {{nickname}} - The {{nickname}} object.
143-
{{#allParams}}
144-
* @param {{nickname}}.{{paramName}} {{^description}}The {{paramName}} object.{{/description}}{{#description}}{{{description}}}{{/description}}
145-
{{/allParams}}
146-
{{/pathParams.0}}
147-
{{/queryParams.0}}
148-
{{#queryParams.0}}
149-
* @param {{nickname}} - The {{nickname}} object.
150-
{{#allParams}}
151-
* @param {{nickname}}.{{paramName}} {{^description}}The {{paramName}} object.{{/description}}{{#description}}{{{description}}}{{/description}}
152-
{{/allParams}}
153-
{{/queryParams.0}}
154-
{{/bodyParams.0}}
155-
{{/allParams.0}}
156-
*/
157-
function {{nickname}}(
111+
return {
112+
addUserAgent,
113+
{{#operation}}
114+
/**
115+
{{#notes}}
116+
* {{&notes}}
117+
{{/notes}}
118+
{{#summary}}
119+
* @summary {{&summary}}
120+
{{/summary}}
158121
{{#allParams.0}}
159122
{{^bodyParams.0}}
160-
{
123+
* @param {{nickname}} - The {{nickname}} object.
161124
{{#allParams}}
162-
{{paramName}},
125+
* @param {{nickname}}.{{paramName}} {{^description}}The {{paramName}} object.{{/description}}{{#description}}{{{description}}}{{/description}}
163126
{{/allParams}}
164-
}: {{#lambda.titlecase}}{{nickname}}{{/lambda.titlecase}}Props,
165127
{{/bodyParams.0}}
166128
{{#bodyParams.0}}
167129
{{^queryParams.0}}
168130
{{^pathParams.0}}
169131
{{#bodyParams.0.isArray}}
170132
{{^bodyParams.1}}
171-
{
172-
{{#allParams}}
173-
{{paramName}},
174-
{{/allParams}}
175-
}: {{#lambda.titlecase}}{{nickname}}{{/lambda.titlecase}}Props,
133+
* @param {{nickname}} - The {{nickname}} object.
134+
{{#allParams}}
135+
* @param {{nickname}}.{{paramName}} {{^description}}The {{paramName}} object.{{/description}}{{#description}}{{{description}}}{{/description}}
136+
{{/allParams}}
176137
{{/bodyParams.1}}
177138
{{/bodyParams.0.isArray}}
178139
{{^bodyParams.0.isArray}}
179-
{{#bodyParams}}
180-
{{paramName}}: {{{dataType}}},
181-
{{/bodyParams}}
140+
* @param {{paramName}} {{^description}}The {{paramName}} object.{{/description}}{{#description}}{{{description}}}{{/description}}
182141
{{/bodyParams.0.isArray}}
183142
{{/pathParams.0}}
184143
{{#pathParams.0}}
185-
{
144+
* @param {{nickname}} - The {{nickname}} object.
186145
{{#allParams}}
187-
{{paramName}},
146+
* @param {{nickname}}.{{paramName}} {{^description}}The {{paramName}} object.{{/description}}{{#description}}{{{description}}}{{/description}}
188147
{{/allParams}}
189-
}: {{#lambda.titlecase}}{{nickname}}{{/lambda.titlecase}}Props,
190148
{{/pathParams.0}}
191149
{{/queryParams.0}}
192150
{{#queryParams.0}}
193-
{
151+
* @param {{nickname}} - The {{nickname}} object.
194152
{{#allParams}}
195-
{{paramName}},
153+
* @param {{nickname}}.{{paramName}} {{^description}}The {{paramName}} object.{{/description}}{{#description}}{{{description}}}{{/description}}
196154
{{/allParams}}
197-
}: {{#lambda.titlecase}}{{nickname}}{{/lambda.titlecase}}Props,
198155
{{/queryParams.0}}
199156
{{/bodyParams.0}}
200157
{{/allParams.0}}
201-
requestOptions?: RequestOptions
202-
) : Promise<{{{returnType}}}> {
203-
const requestPath = '{{{path}}}'{{#pathParams}}.replace(
204-
{{=<% %>=}}
205-
'{<%baseName%>}',
206-
<%={{ }}=%>
207-
encodeURIComponent(String({{paramName}}))
208-
){{/pathParams}};
209-
const headers: Headers = {};
210-
const queryParameters: QueryParameters = {};
211-
212-
{{#allParams}}
213-
{{#required}}
214-
if ({{#isBoolean}}{{paramName}} === null || {{paramName}} === undefined{{/isBoolean}}{{^isBoolean}}!{{paramName}}{{/isBoolean}}) {
215-
throw new Error('Parameter `{{paramName}}` is required when calling `{{nickname}}`.');
216-
}
158+
*/
159+
{{nickname}}(
160+
{{#allParams.0}}
161+
{{^bodyParams.0}}
162+
{
163+
{{#allParams}}
164+
{{paramName}},
165+
{{/allParams}}
166+
}: {{#lambda.titlecase}}{{nickname}}{{/lambda.titlecase}}Props,
167+
{{/bodyParams.0}}
168+
{{#bodyParams.0}}
169+
{{^queryParams.0}}
170+
{{^pathParams.0}}
171+
{{#bodyParams.0.isArray}}
172+
{{^bodyParams.1}}
173+
{
174+
{{#allParams}}
175+
{{paramName}},
176+
{{/allParams}}
177+
}: {{#lambda.titlecase}}{{nickname}}{{/lambda.titlecase}}Props,
178+
{{/bodyParams.1}}
179+
{{/bodyParams.0.isArray}}
180+
{{^bodyParams.0.isArray}}
181+
{{#bodyParams}}
182+
{{paramName}}: {{{dataType}}},
183+
{{/bodyParams}}
184+
{{/bodyParams.0.isArray}}
185+
{{/pathParams.0}}
186+
{{#pathParams.0}}
187+
{
188+
{{#allParams}}
189+
{{paramName}},
190+
{{/allParams}}
191+
}: {{#lambda.titlecase}}{{nickname}}{{/lambda.titlecase}}Props,
192+
{{/pathParams.0}}
193+
{{/queryParams.0}}
194+
{{#queryParams.0}}
195+
{
196+
{{#allParams}}
197+
{{paramName}},
198+
{{/allParams}}
199+
}: {{#lambda.titlecase}}{{nickname}}{{/lambda.titlecase}}Props,
200+
{{/queryParams.0}}
201+
{{/bodyParams.0}}
202+
{{/allParams.0}}
203+
requestOptions?: RequestOptions
204+
) : Promise<{{{returnType}}}> {
205+
const requestPath = '{{{path}}}'{{#pathParams}}.replace(
206+
{{=<% %>=}}
207+
'{<%baseName%>}',
208+
<%={{ }}=%>
209+
encodeURIComponent(String({{paramName}}))
210+
){{/pathParams}};
211+
const headers: Headers = {};
212+
const queryParameters: QueryParameters = {};
217213

218-
{{#vars}}
219-
{{#required}}
220-
if ({{#isBoolean}}{{paramName}}.{{baseName}} === null || {{paramName}}.{{baseName}} === undefined{{/isBoolean}}{{^isBoolean}}!{{paramName}}.{{baseName}}{{/isBoolean}}) {
221-
throw new Error('Parameter `{{paramName}}.{{baseName}}` is required when calling `{{nickname}}`.');
222-
}
223-
{{/required}}
224-
{{/vars}}
214+
{{#allParams}}
215+
{{#required}}
216+
if ({{#isBoolean}}{{paramName}} === null || {{paramName}} === undefined{{/isBoolean}}{{^isBoolean}}!{{paramName}}{{/isBoolean}}) {
217+
throw new Error('Parameter `{{paramName}}` is required when calling `{{nickname}}`.');
218+
}
225219

226-
{{/required}}
227-
{{/allParams}}
228-
{{#queryParams}}
229-
if ({{paramName}} !== undefined) {
230-
queryParameters['{{baseName}}'] = {{paramName}}.toString();
231-
}
220+
{{#vars}}
221+
{{#required}}
222+
if ({{#isBoolean}}{{paramName}}.{{baseName}} === null || {{paramName}}.{{baseName}} === undefined{{/isBoolean}}{{^isBoolean}}!{{paramName}}.{{baseName}}{{/isBoolean}}) {
223+
throw new Error('Parameter `{{paramName}}.{{baseName}}` is required when calling `{{nickname}}`.');
224+
}
225+
{{/required}}
226+
{{/vars}}
232227

233-
{{/queryParams}}
234-
{{#headerParams}}
235-
headers['{{baseName}}'] = {{paramName}};
236-
{{/headerParams}}
228+
{{/required}}
229+
{{/allParams}}
230+
{{#queryParams}}
231+
if ({{paramName}} !== undefined) {
232+
queryParameters['{{baseName}}'] = {{paramName}}.toString();
233+
}
237234

238-
const request: Request = {
239-
method: '{{httpMethod}}',
240-
path: requestPath,
241-
{{#bodyParam}}
242-
data: {{paramName}},
243-
{{/bodyParam}}
244-
};
235+
{{/queryParams}}
236+
{{#headerParams}}
237+
headers['{{baseName}}'] = {{paramName}};
238+
{{/headerParams}}
245239

246-
return transporter.request(request, {
247-
queryParameters,
248-
headers,
249-
}, requestOptions);
250-
}
240+
const request: Request = {
241+
method: '{{httpMethod}}',
242+
path: requestPath,
243+
{{#bodyParam}}
244+
data: {{paramName}},
245+
{{/bodyParam}}
246+
};
251247

252-
{{/operation}}
248+
return transporter.request(request, {
249+
queryParameters,
250+
headers,
251+
}, requestOptions);
252+
},
253253

254-
return { addUserAgent, {{#operation}}{{nickname}},{{/operation}} };
254+
{{/operation}}
255+
};
255256
}
256257

257258
export type {{capitalizedApiName}}Api = ReturnType<typeof create{{capitalizedApiName}}Api>;

templates/javascript/model.mustache

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ export type {{classname}} = {{#oneOf}}{{.}} {{^-last}}|{{/-last}} {{/oneOf}}{{#a
1616
*/
1717
{{/description}}
1818
{{^isEnum}}
19-
{{#parent}}
20-
{{! TODO: Add back 'extends parent' when we understand where parent come from, but for now it's breaking the code}}
21-
{{/parent}}
2219
export type {{classname}} = {
2320
{{#vars}}
2421
{{#description}}

0 commit comments

Comments
 (0)