[BUG][Typescript-axios] Typescript 4.0.x: the operand of a 'delete' operator must be optional
See original GitHub issueBug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- What’s the version of OpenAPI Generator used?
- Have you search for related issues/PRs?
- What’s the actual output vs expected output?
- [Optional] Bounty to sponsor the fix (example)
Description
Upgrading to TypeScript 4.0.x now causes issues within the AxiosParamCreator
function. It will complain about:
generated/api.ts:149:20 - error TS2790: The operand of a 'delete' operator must be optional.
Further reference: https://devblogs.microsoft.com/typescript/announcing-typescript-4-0/#operands-for-delete-must-be-optional
openapi-generator version
v5.0.0-beta
OpenAPI declaration file content or url
https://github.com/sebas2day/typescript-axios-error
Generation Details
typescript-axios
Steps to reproduce
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.0.0-beta/openapi-generator-cli-5.0.0-beta.jar
yarn
java -jar openapi-generator-cli-5.0.0-beta.jar generate -i spec.yaml -g typescript-axios -o generated
yarn tsc -b -f
Outcome:
generated/api.ts:71:20 - error TS2790: The operand of a 'delete' operator must be optional.
71 delete localVarUrlObj.search;
~~~~~~~~~~~~~~~~~~~~~
Found 1 error.
error Command failed with exit code 1.
Related issues/PRs
NA
Suggest a fix
Instead of using delete
it would be better to assign it with null
.
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (4 by maintainers)
Top Results From Across the Web
What is the logic behind the TypeScript error "The operand of ...
/*When using the delete operator in strictNullChecks, the operand must now be any, unknown, never, or be optional (in that it contains undefined...
Read more >The operand of a 'delete' operator must be optional in TS
The error "the operand of a 'delete' operator must be optional" occurs when we try to use the `delete` operator to delete a...
Read more >[Solved] The operand of a 'delete' operator must be optional
In this article, we will take a look at what is The operand of a 'delete' operator must be optional error means and...
Read more >the operand of a 'delete' operator must be optional - You.com
The operand of a 'delete' operator must be optional. TypeScript allows developers to describe a set of rules which it has to obey....
Read more >What's new with TypeScript 4.0? - Hao's learning log
interface Thing { prop: string; } function f(x: Thing) { delete x.prop; // ~~~~~~ // error! The operand of a 'delete' operator must...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@luixal this should be fixed in 5.0.0 beta
@sebas2day I think that is a typescript issue. (https://github.com/DefinitelyTyped/DefinitelyTyped/issues/34960)