Skip to content

Commit

Permalink
Fix Typescript errors with 'strictNullChecks' mode enabled (#4658)
Browse files Browse the repository at this point in the history
error TS2454: Variable 'contentTypeHeader' is used before being assigned.
error TS2345: Argument of type 'FetchAPI | undefined' is not assignable to parameter of type 'FetchAPI'.
  • Loading branch information
megaboich authored and wing328 committed Jan 29, 2017
1 parent 1d7ba4c commit d82c2bb
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export const {{classname}}FetchParamCreator = {
{{/hasQueryParams}}
let fetchOptions: RequestInit = {{#supportsES6}}Object.{{/supportsES6}}assign({}, { method: "{{httpMethod}}" }, options);

let contentTypeHeader: Dictionary<string>;
let contentTypeHeader: Dictionary<string> = {};
{{#hasFormParams}}
contentTypeHeader = { "Content-Type": "application/x-www-form-urlencoded" };
fetchOptions.body = querystring.stringify({
Expand Down Expand Up @@ -135,7 +135,7 @@ export const {{classname}}Fp = {
* {{notes}}{{/notes}}{{#allParams}}
* @param {{paramName}} {{description}}{{/allParams}}
*/
{{nickname}}({{#hasParams}}params: { {{#allParams}}"{{paramName}}"{{^required}}?{{/required}}: {{{dataType}}}; {{/allParams}} }, {{/hasParams}}options?: any): (fetch: FetchAPI, basePath?: string) => Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}any{{/returnType}}> {
{{nickname}}({{#hasParams}}params: { {{#allParams}}"{{paramName}}"{{^required}}?{{/required}}: {{{dataType}}}; {{/allParams}} }, {{/hasParams}}options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}any{{/returnType}}> {
const fetchArgs = {{classname}}FetchParamCreator.{{nickname}}({{#hasParams}}params, {{/hasParams}}options);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
Expand Down

0 comments on commit d82c2bb

Please sign in to comment.