OpenAPITools / OpenAPITools/openapi-generator

[BUG][Typescript-Node] TS7005 error when not creating APIs

Open
#16,098 0 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?
Description

I'd like to generate typescript-node models from an input file without generating the APIs.

The generator produces an api/apis.ts file that is essentially empty (as expected), but the Typescript 5 compiler produces a TS7005 error on the line: export const APIS = []; because APIS is implicitly typed. I believe Typescript has gotten pickier about typing through the years 😄

openapi-generator version

6.6.0

OpenAPI declaration file content or url

Seems to happen with any yaml (probably json, too). I just picked one off the internet

https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/examples/v3.0/petstore.yaml

Generation Details
Steps to reproduce

npx @openapitools/openapi-generator-cli generate -i XXX.yaml -g typescript-node -o generated --additional-properties supportsES6=true --global-property models,supportingFiles

Related issues/PRs
Suggest a fix

Add typing to this line:

https://github.com/OpenAPITools/openapi-generator/blob/92193f7159d62419634c51eb7d2e9a4e0697d283/modules/openapi-generator/src/main/resources/typescript-node/api-all.mustache#L22

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 with modules/openapi-generator/src/main/resources/typescript-node/api-all.mustache at the APIS declaration around line 22. Reproduce the typescript-node generation command with models and supportingFiles, then verify the generated output no longer raises TS7005 when compiled with TypeScript 5.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, tooling
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.