Skip to content

Commit ecf90cd

Browse files
Cellulefabien0102
andauthored
fix: Fixed fetcher template to compile when noUncheckedIndexedAccess ts compile option is set (#228)
* fix: Fixed fetcher template to compile when noUncheckedIndexedAccess ts compile option is set * Fallback on an empty value if no pathParams found --------- Co-authored-by: Fabien BERNARD <[email protected]>
1 parent 3392588 commit ecf90cd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

plugins/typescript/src/templates/fetcher.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export async function ${camel(prefix)}Fetch<
8585
* the correct boundary.
8686
* https://developer.mozilla.org/en-US/docs/Web/API/FormData/Using_FormData_Objects#sending_files_using_a_formdata_object
8787
*/
88-
if (requestHeaders["Content-Type"].toLowerCase().includes("multipart/form-data")) {
88+
if (requestHeaders["Content-Type"]?.toLowerCase().includes("multipart/form-data")) {
8989
delete requestHeaders["Content-Type"];
9090
}
9191
@@ -135,6 +135,6 @@ const resolveUrl = (
135135
) => {
136136
let query = new URLSearchParams(queryParams).toString();
137137
if (query) query = \`?\${query}\`;
138-
return url.replace(/\\{\\w*\\}/g, (key) => pathParams[key.slice(1, -1)]) + query;
138+
return url.replace(/\\{\\w*\\}/g, (key) => pathParams[key.slice(1, -1)] ?? "") + query;
139139
};
140140
`;

0 commit comments

Comments
 (0)