ng-openapi-gen
ng-openapi-gen copied to clipboard
ES5 compatibility
I had to migrate an existing Angular project from Swagger 2 using ng-swagger-gen
to OpenAPI 3 using ng-openapi-gen
.
One of the issues I encountered was that the generated code seems not to be ES5 compliant. I had to change the tsconfig
target from es5
to es2015
to get rid of building problems.
(As a consequence, I now can't run tests using Karma/PhantomJS and trying to use Babel as a workaround.)
- Is there a way to make
ng-openapi-gen
produce ES5 compliant code only? - Is there anything I might have misunderstood in the process?
- If ES6 is an absolute requirement when using this code generator, could you add this information in the README?
Regards.
What exact error do you have?
The type of errors I get is like this:
Error: src/app/.../request-builder.ts:338:30 - error TS2569:
Type 'IterableIterator<QueryParameter>' is not an array type or a string type.
Use compiler option '--downlevelIteration' to allow iterating of iterators.
338 for (const queryParam of this._query.values()) {
About my previous comment, I now know that PhantomJS is deprecated and is not compatible with ES6.
If you edit the request-build.ts
file, and change that line to for (const queryParam of [...this._query.values()]) {
, does it work?
I get the same error with the proposed change. I think that the compatibility problem comes from the type returned by values()
which is IterableIterator
. I did not have time to figure out exactly what is not ES5 compatible.
By the way, the same problem exists for HeaderParameter
and PathParameter
.
Closing for lack of activity