dataforseo / TypeScriptClient

MIT License
5 stars 1 forks source link

Getting "'item is possibly undefined" when building a project #3

Open dariodjuric opened 1 month ago

dariodjuric commented 1 month ago

Hello,

We have a NextJS project using version 1.0.19 of the dataforseo-client library. When building the project, NextJS will by default validate the TypeScript code of not just the project, but the libraries as well.

We get the following error in the dataforseo-client library:

../../node_modules/dataforseo-client/main.ts:23153:48
Type error: 'item' is possibly 'undefined'.

  23151 |             data["delivery_services"] = [];
  23152 |             for (let item of this.delivery_services)
> 23153 |                 data["delivery_services"].push(item.toJSON());
        |                                                ^
  23154 |         }
  23155 |         super.toJSON(data);
  23156 |         return data;

Is this something that can be resolved within the library? We are currently ignoring TS build errors, but this is not an ideal solution.

lVics commented 1 month ago

Hi, thanks for the message. This code is generated by 'NSwag' based on our .yaml files describing the API. But we don't see any way to customize the code generation parameters for this case. If something changes in this matter, we will inform you