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
v5.0.0-beta
https://github.com/sebas2day/typescript-axios-error
typescript-axios
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.0.0-beta/openapi-generator-cli-5.0.0-beta.jaryarnjava -jar openapi-generator-cli-5.0.0-beta.jar generate -i spec.yaml -g typescript-axios -o generatedyarn tsc -b -fOutcome:
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.
NA
Instead of using delete it would be better to assign it with null.
@sebas2day would you like to fix this?
@macjohnny Yes, I'll make a PR for it
Ah looks like this issue implicitly got fixed by this PR #6960 but is not released yet :)
There's still some compiling issues however:
generated/api.ts:56:40 - error TS2304: Cannot find name 'URL'.
56 const localVarUrlObj = new URL(localVarPath, 'https://example.com');
~~~
generated/api.ts:69:31 - error TS2304: Cannot find name 'URLSearchParams'.
69 const query = new URLSearchParams(localVarUrlObj.search);
~~~~~~~~~~~~~~~
generated/api.ts:76:42 - error TS2304: Cannot find name 'URLSearchParams'.
76 localVarUrlObj.search = (new URLSearchParams(query)).toString();
~~~~~~~~~~~~~~~
Found 3 errors.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I'll make a fix
@sebas2day the URL class should be available in the browser as well as in node environments: https://nodejs.org/api/url.html#url_new_url_input_base
@macjohnny Yes, but the compilation will break when you don't have the "lib": ["dom"] included in your tsconfig like within the tests. For my use case I'm working in a node-only environment where I don't want to include this lib.
@sebas2day
I think that is a typescript issue. (https://github.com/DefinitelyTyped/DefinitelyTyped/issues/34960)
Just hit this issue (the The operand of a 'delete' operator must be optional one) running version 4.3.1.
Any workaround?
Thanks!
@luixal this should be fixed in 5.0.0 beta
Just add global
declare module 'url' {
interface Url {
search: string | null | undefined;
}
}
Most helpful comment
@luixal this should be fixed in 5.0.0 beta