openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

[BUG] [typescript-fetch] Compile error when using "noImplicitOverride" in tsconfig and ES2022

Open tomsontom opened this issue 3 years ago • 3 comments

Bug Report Checklist

  • [x] Have you provided a full/minimal spec to reproduce the issue?
  • [x] Have you validated the input using an OpenAPI validator (example)?
  • [x] Have you tested with the latest master to confirm the issue still exists?
  • [x] Have you searched for related issues/PRs?
  • [x] What's the actual output vs expected output?
  • [ ] [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

This is similar to issue #12948 but only happens when you use ES2022 as the target because there cause?: unknown has been added to Error in lib.es2022.error.d.ts

openapi-generator version

6.2.0

OpenAPI declaration file content or url

N/A

Generation Details

N/A

Steps to reproduce
  • clone https://github.com/OpenAPITools/openapi-generator/tree/master/samples/client/petstore/typescript-fetch/builds/es6-target
  • Modify tsconfig.json
diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/tsconfig.json b/samples/client/petstore/typescript-fetch/builds/es6-target/tsconfig.json
index 250280d9ab0..ec9f49f3844 100644
--- a/samples/client/petstore/typescript-fetch/builds/es6-target/tsconfig.json
+++ b/samples/client/petstore/typescript-fetch/builds/es6-target/tsconfig.json
@@ -5,6 +5,11 @@
     "module": "commonjs",
     "moduleResolution": "node",
     "outDir": "dist",
+    "noImplicitOverride": true,
+    "lib": [
+      "es2022",
+      "dom"
+    ],
     "typeRoots": [
       "node_modules/@types"
     ]
  • See the build fail with
src/runtime.ts:245:17 - error TS4115: This parameter property must have an 'override' modifier because it overrides a member in base class 'Error'.

245     constructor(public cause: Error, msg?: string) {
                    ~~~~~~~~~~~~~~~~~~~


Found 1 error in src/runtime.ts:245
Related issues/PRs
Suggest a fix

As this problem only occurs with ES2022 I guess one would have to introduce a special switch to know what ES-Version the generated code needs to compile with.

tomsontom avatar Jan 24 '23 10:01 tomsontom

Any news about this issue?

jycr avatar Jan 07 '25 15:01 jycr

Any update on this?

magulin avatar Apr 24 '25 06:04 magulin

Any update on this?

mfarahat avatar Mar 25 '26 19:03 mfarahat