OpenAPITools / OpenAPITools/openapi-generator

[BUG] Docker: generation failed for Angular versions before 12 because of @types/node 18.13.0 update

Open
#14,805 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Bug Report Checklist
  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

We are using Docker image of openapi-generator-cli to generate TypeScript code for Angular 11.2.14.
https://hub.docker.com/r/openapitools/openapi-generator-cli/tags

Till recent time everything worked fine, but with version 18.13.0 of @types/node it basically drops the support of Angular version before 12. https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/64262

Here is our generation script:

docker run --rm \
    -v $GENERATED_CODE_DIR:/generated-code \
    -v $SWAGGER_SPEC_DIR:/input-spec openapitools/openapi-generator-cli:v5.3.1 \
    generate -g typescript-angular \
    -i //input-spec/$SWAGGER_FILE_PREFIX-swagger.json \
    -o //generated-code \
    --additional-properties=ngVersion=11.2.14,npmName=api-client-$SWAGGER_FILE_PREFIX

We are using version 5.3.1, but the problem is also confirmed on 6.2.0 and 6.4.0

Here is the part of generated package-lock.json:

    "@types/node": {
      "version": "18.14.1",
      "resolved": "https://registry.npmjs.org/@types/node/-/node-18.13.0.tgz",
      "integrity": "sha512-gC3TazRzGoOnoKAhUx+Q0t8S9Tzs74z7m0ipwGpSqQrleP14hKxP4/JUeEQcD3W1/aIpnWl8pHowI7WokuZpXg==",
      "dev": true
    },

And here the errors we're getting when trying to build the API code:

✖ Compiling TypeScript sources through NGC
ERROR: node_modules/@types/node/ts4.8/test.d.ts:612:34 - error TS1005: '?' expected.

612             : F extends abstract new (...args: any) => infer T
                                     ~~~
node_modules/@types/node/ts4.8/test.d.ts:613:17 - error TS1005: ':' expected.

613                 ? T
                    ~
node_modules/@types/node/ts4.8/test.d.ts:614:17 - error TS1005: ',' expected.

614                 : unknown,
                    ~
node_modules/@types/node/ts4.8/test.d.ts:617:34 - error TS1005: '?' expected.

617             : F extends abstract new (...args: infer Y) => any
                                     ~~~
node_modules/@types/node/ts4.8/test.d.ts:618:17 - error TS1005: ':' expected.

618                 ? Y
                    ~
node_modules/@types/node/ts4.8/test.d.ts:619:17 - error TS1005: ',' expected.

619                 : unknown[],
                    ~
node_modules/@types/node/ts4.8/test.d.ts:619:26 - error TS1005: ',' expected.

619                 : unknown[],
                             ~
node_modules/@types/node/ts4.8/test.d.ts:620:5 - error TS1109: Expression expected.

620     > {
        ~
node_modules/@types/node/ts4.8/test.d.ts:624:24 - error TS1005: ',' expected.

624         arguments: Args;
                           ~
node_modules/@types/node/ts4.8/test.d.ts:628:35 - error TS1005: ',' expected.

628         error: unknown | undefined;
                                      ~
node_modules/@types/node/ts4.8/test.d.ts:634:39 - error TS1005: ',' expected.

634         result: ReturnType | undefined;
                                          ~
node_modules/@types/node/ts4.8/test.d.ts:638:21 - error TS1005: ',' expected.

638         stack: Error;
                        ~
node_modules/@types/node/ts4.8/test.d.ts:643:19 - error TS1005: ',' expected.

643         target: F extends abstract new (...args: any) => any ? F : undefined;
                      ~~~~~~~
node_modules/@types/node/ts4.8/test.d.ts:643:27 - error TS1005: ':' expected.

643         target: F extends abstract new (...args: any) => any ? F : undefined;
                              ~~~~~~~~
node_modules/@types/node/ts4.8/test.d.ts:643:36 - error TS1005: ',' expected.

643         target: F extends abstract new (...args: any) => any ? F : undefined;
                                       ~~~
node_modules/@types/node/ts4.8/test.d.ts:643:55 - error TS1005: '{' expected.

643         target: F extends abstract new (...args: any) => any ? F : undefined;
                                                          ~~
node_modules/@types/node/ts4.8/test.d.ts:643:64 - error TS1005: ',' expected.

643         target: F extends abstract new (...args: any) => any ? F : undefined;
                                                                   ~
node_modules/@types/node/ts4.8/test.d.ts:643:77 - error TS1005: ',' expected.

643         target: F extends abstract new (...args: any) => any ? F : undefined;
                                                                                ~
node_modules/@types/node/ts4.8/test.d.ts:647:22 - error TS1005: ',' expected.

647         this: unknown;
                         ~

Just a few days ago the @types/node version in generated package-lock.json was "18.11.19" and everything worked fine.

If we will try to generate an API for Angular 12.2 - there are no errors.

openapi-generator version

Docker image of version 5.3.1
https://hub.docker.com/layers/openapitools/openapi-generator-cli/v5.3.1/images/sha256-fd605a2b72f40d1491b128cab58bbcd82159a5accc4dd0f01024dac36262ccfc?context=explore

OpenAPI declaration file content or url

Any OpenAPI json/yaml file with TypeScript target using ngVersion=11.2.14.
The content of the API itself is irrelevant.

Generation Details
Steps to reproduce
Related issues/PRs
Suggest a fix

Use specific @types/node version for every Angular version supported.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Docker command for the typescript-angular generator with ngVersion=11.2.14 and inspect the generated package-lock.json and build errors. Trace where the generated Angular dependencies are selected; done means Angular versions before 12 receive a compatible @types/node version and the generated API builds successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, docker, typescript
Domain
build-system, frontend, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.