cyclosproject / ng-openapi-gen

An OpenAPI 3.0 codegen for Angular
MIT License
397 stars 132 forks source link

Improve typescript pair type in request-builder.ts #176

Closed briceruzand closed 3 years ago

briceruzand commented 3 years ago

With Typescript compiler option "noUncheckedIndexedAccess": true enabled on my project, it throw me some error. https://devblogs.microsoft.com/typescript/announcing-typescript-4-1/#no-unchecked-indexed-access

request-builder.ts:262:72 - error TS2345: Argument of type 'string | undefined' is not assignable to parameter of type 'string | number | boolean'.
262             this._bodyContent = pairs.map((p) => `${encodeURIComponent(p[0])}=${encodeURIComponent(p[1])}`).join('&');

p[0] and p[1] maybe be undefined according to typescript compiler with this option.

Changing type from :

const pairs: string[][] = [];

to :

const pairs: Array<[string, string]> = [];

Remove that error.

Thx a lot for your tool

luisfpg commented 3 years ago

Thanks for the PR. Released with 0.19.1.