Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #12542
Closed
Open
Issue created Jun 06, 2022 by Administrator@rootContributor4 of 6 checklist items completed4/6 checklist items

[BUG] [typescript-fetch] cannot compile with noUncheckedIndexedAccess

Created by: javier-garcia-meteologica

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

When noUncheckedIndexedAccess is enabled in tsconfig.json, openapi generated code doesn't compile.

The problem is that params[key] could be undefined but that type is not listed in the value argument of querystringSingleKey.

https://github.com/OpenAPITools/openapi-generator/blob/6948f1551448194c9d0f6881eb207c99d3b85bf0/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache#L258-L263

[tsl] ERROR in .../src/api/runtime.ts(263,47)                                                        
      TS2345: Argument of type 'string | number | boolean | HTTPQuery | (string | number | boolean | null)[] | Set<string | number | boolean | null> | null | undefined' is not assignable to parameter of type 'string | number | boolean | HTTPQuery | (string | number | boolean | null)[] | Set<string | number | boolean | null> | null'.                                                                                                                                                                                                 
  Type 'undefined' is not assignable to type 'string | number | boolean | HTTPQuery | (string | number | boolean | null)[] | Set<string | number | boolean | null> | null'.
openapi-generator version

6.0.0

OpenAPI declaration file content or url
{
"$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json",
"spaces": 2,
"generator-cli": {
  "version": "6.0.0",
  "generators": {
    "typescript": {
      "generatorName": "typescript-fetch",
      "output": "#{cwd}/src/api",
      "inputSpec": "../backend/src/definitions/auth/v1/openapi.json",
      "additionalProperties": {
        "typescriptThreePlus": true,
        "withoutRuntimeChecks": true
      }
    }
  }
}
}
Generation Details
npm exec --package=@openapitools/openapi-generator-cli -- openapi-generator-cli generate
Steps to reproduce
Related issues/PRs
Suggest a fix

#12543

Assignee
Assign to
Time tracking