[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
.
[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