Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] [typescript-angular] TypeScript compilers errors for generated code if configuration "exactOptionalPropertyTypes" is enabled #20450

Open
4 of 5 tasks
jase88 opened this issue Jan 12, 2025 · 0 comments · May be fixed by #20451

Comments

@jase88
Copy link
Contributor

jase88 commented Jan 12, 2025

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

Every generated openapi code from typescript-angular fails, if the tsconfig.json compiler option exactOptionalPropertyTypes is set to true.

The reason is that in the constructor of configuration.ts a potential undefined value is assigned, although the corresponding property is only optional.
e.g.

export interface ConfigurationParameters {
    //...
    username?: string;
    //...
}

export class Configuration {
    // ...
    username?: string;
    // ...
    constructor(configurationParameters: ConfigurationParameters = {}) {
        // ...
        this.username = configurationParameters.username;
        // ...
    }
}
openapi-generator version

v7.10.0
probably no regression

OpenAPI declaration file content or url

this error occurs on every API definition. Steps below described to get the error within the given angular examples in the repo

Steps to reproduce
  • modify samples/client/petstore/typescript-angular-v19/builds/default/tsconfig.json and add
    "strictNullChecks": true,
    "exactOptionalPropertyTypes": true,

to the compilerOptions

  • run ./bin/ts-typecheck-all.sh
Related issues/PRs

#14793

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant