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

fix(typescript): missing override directives / satisfy noImplicitOverride #19896

Merged
merged 2 commits into from
Oct 17, 2024

Conversation

joscha
Copy link
Contributor

@joscha joscha commented Oct 17, 2024

In Deno v2 a generator which used to work with v1.x errors with:

error: TS4114 [ERROR]: This member must have an 'override' modifier because it overrides a member in the base class 'Error'.
    name: "RequiredError" = "RequiredError";
    ~~~~
    at file:///Users/joscha/dev/affinity-node/src/v2/generated/apis/baseapi.ts:33:5

TS4115 [ERROR]: This parameter property must have an 'override' modifier because it overrides a member in base class 'ResponseContext'.
        public httpStatusCode: number,
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at file:///Users/joscha/dev/affinity-node/src/v2/generated/http/http.ts:237:9

TS4115 [ERROR]: This parameter property must have an 'override' modifier because it overrides a member in base class 'ResponseContext'.
        public headers: Headers,
        ~~~~~~~~~~~~~~~~~~~~~~~
    at file:///Users/joscha/dev/affinity-node/src/v2/generated/http/http.ts:238:9

TS4115 [ERROR]: This parameter property must have an 'override' modifier because it overrides a member in base class 'ResponseContext'.
        public body: ResponseBody,
        ~~~~~~~~~~~~~~~~~~~~~~~~~
    at file:///Users/joscha/dev/affinity-node/src/v2/generated/http/http.ts:239:9

Found 4 errors.

due to noImplicitOverride (Ensure overriding members in derived classes are marked with an override modifier) being enabled by default.

The first one is due to: https://github.com/microsoft/TypeScript/blob/b8e4ed8aeb0b228f544c5736908c31f136a9f7e3/src/lib/es5.d.ts#L1057-L1061

The other three in http.ts are simple, as all three properties are already public on the superclass and thus don't need to be exported again:

public httpStatusCode: number,
public headers: Headers,
public body: ResponseBody


There is currently no fixture in the repository capturing these changes. It might be worth adding a change to a sample, so these changes will show up as diff in the future

Alternatively we could make the tsconfig more strict, which would be a good thing in general I think? @macjohnny WDYT?


PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh ./bin/configs/*.yaml
    ./bin/utils/export_docs_generators.sh
    
    (For Windows users, please run the script in Git BASH)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • File the PR against the correct branch: master (upcoming 7.x.0 minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • If your PR is targeting a particular programming language, @mention the technical committee members: @TiFu (2017/07) @taxpon (2017/07) @sebastianhaas (2017/07) @kenisteward (2017/07) @Vrolijkx (2017/09) @macjohnny (2018/01) @topce (2018/10) @akehir (2019/07) @petejohansonxo (2019/11) @amakhrov (2020/02) @davidgamero (2022/03) @mkusaka (2022/04) @joscha (2024/10)

@@ -37,7 +37,7 @@ export class BaseAPIRequestFactory {
* @extends {Error}
*/
export class RequiredError extends Error {
name: "RequiredError" = "RequiredError";
override name: "RequiredError" = "RequiredError";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public body: ResponseBody,
httpStatusCode: number,
headers: Headers,
body: ResponseBody,
public data: T,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see

public httpStatusCode: number,
public headers: Headers,
public body: ResponseBody

@joscha joscha changed the title fix(typescript): missing override directives fix(typescript): missing override directives / satisfy noImplicitOverride Oct 17, 2024
@macjohnny
Copy link
Member

@joscha can you re-generate the samples so we can merge?

@joscha
Copy link
Contributor Author

joscha commented Oct 17, 2024

@joscha can you re-generate the samples so we can merge?

Will do. What are your thoughts on tightening the tsconfig?

@joscha
Copy link
Contributor Author

joscha commented Oct 17, 2024

@macjohnny this is ready to 🚢

@macjohnny macjohnny merged commit 23bd50f into OpenAPITools:master Oct 17, 2024
18 checks passed
@joscha joscha deleted the joscha/fix-type-errors branch October 17, 2024 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants