question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG][Typescript-axios] Typescript 4.0.x: the operand of a 'delete' operator must be optional

See original GitHub issue

Bug 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
  1. wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.0.0-beta/openapi-generator-cli-5.0.0-beta.jar
  2. yarn
  3. java -jar openapi-generator-cli-5.0.0-beta.jar generate -i spec.yaml -g typescript-axios -o generated
  4. 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:closed
  • Created 3 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
macjohnnycommented, Sep 16, 2020

@luixal this should be fixed in 5.0.0 beta

2reactions
sapphi-redcommented, Sep 8, 2020
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found