OpenAPITools / OpenAPITools/openapi-generator
[BUG] [typescript-fetch] Compile error when using "noImplicitOverride" in tsconfig and ES2022
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
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?
- [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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with samples/client/petstore/typescript-fetch/builds/es6-target/tsconfig.json and the generated src/runtime.ts location reported in the compiler error. Reproduce the build with noImplicitOverride enabled and the ES2022 and DOM libraries, then verify that the generated client compiles successfully without the TS4115 error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100