You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use the spec file and command provided above to generate a client.
Then run the command npx tsc configuration.ts --lib esnext --strictNullChecks.
Ignore the error Cannot find module '@angular/common/http'.
Observe two errors stating Object is possibly 'undefined'
Description
The code generated by the typescript-angular template results in code that fails the
strictNullChecks
compiler option for Typescriptopenapi-generator version
5.0.1 - issue added in 5.0.0 via #6953
OpenAPI declaration file content or url
Command line used for generation
openapi-generator generate -g typescript-angular -i openapi.yml
Steps to reproduce
Use the spec file and command provided above to generate a client.
Then run the command
npx tsc configuration.ts --lib esnext --strictNullChecks
.Ignore the error
Cannot find module '@angular/common/http'
.Observe two errors stating
Object is possibly 'undefined'
Related issues/PRs
Not that I can see
Suggest a fix/enhancement
https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/typescript-angular/configuration.mustache#L67
The code could be changed to use Optional Chaining (?.) to access the keys on
this.apiKeys
, sinceapiKeys
is nullable. e.g.this.apiKeys?.['{{name}}']
Alternatively, it could simply check for the truthiness of
apiKeys
before accessing it.The text was updated successfully, but these errors were encountered: