Swagger-codegen: [typescript-node] Generated client has strict class initialisation issue

Created on 12 Mar 2018  路  4Comments  路  Source: swagger-api/swagger-codegen

Description

The typescript-node generated client has an issue with strict class initialisation. See https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-7.html section 'Strict Class Initialization'. The generator generates various authentication types (HttpBasicAuth, ApiKeyAuth, ...) which cause typescript transpilation to fail with:

typescript-node/api.ts(877,12): error TS2564: Property 'username' has no initializer and is not definitely assigned in the constructor.
typescript-node/api.ts(878,12): error TS2564: Property 'password' has no initializer and is not definitely assigned in the constructor.
typescript-node/api.ts(887,12): error TS2564: Property 'apiKey' has no initializer and is not definitely assigned in the constructor.
typescript-node/api.ts(902,12): error TS2564: Property 'accessToken' has no initializer and is not definitely assigned in the constructor.
typescript-node/api.ts(912,12): error TS2564: Property 'username' has no initializer and is not definitely assigned in the constructor.
typescript-node/api.ts(913,12): error TS2564: Property 'password' has no initializer and is not definitely assigned in the constructor.

Swagger-codegen version

2.4.0-SNAPSHOT

Swagger declaration file content or url

petstore.yaml

Command line used for generation
swagger-codegen generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l typescript-node -o samples/client/petstore/typescript-node/default"
Steps to reproduce
  1. Generate client
  2. Build client with typescript option --strictPropertyInitialization enabled.
Related issues/PRs

N/A

Suggest a fix/enhancement

Most helpful comment

I'm still seeing this issue in master. Did the referenced PR actually fix this for the generated client code or just for this library's code?

All 4 comments

Submitted PR #7837 to address this issue.

Had some issues with my author info. Will have to close and open a new PR. Sorry about this.

Closing issue as fix merged to master. Thanks!

I'm still seeing this issue in master. Did the referenced PR actually fix this for the generated client code or just for this library's code?

Was this page helpful?
0 / 5 - 0 ratings