fix(typescript-angular): enable "exactOptionalPropertyTypes" and ensure assignments align with type definition#20451
Conversation
…re assignments align with type definition
|
@TiFu (2017/07) @taxpon (2017/07) @sebastianhaas (2017/07) @kenisteward (2017/07) @Vrolijkx (2017/09) @macjohnny (2018/01) @topce (2018/10) @akehir (2019/07) @petejohansonxo (2019/11) @amakhrov (2020/02) @davidgamero (2022/03) @mkusaka (2022/04) @joscha (2024/10) When you have a moment, could you please take a look at my merge request and share your feedback? Thanks a lot! |
| responseType: <any>responseType_, | ||
| {{/isResponseFile}} | ||
| withCredentials: this.configuration.withCredentials, | ||
| ...(withCredentials ? { withCredentials } : {}), |
There was a problem hiding this comment.
Maybe I misunderstand the suggestion to use the nullish coalescing operator, but if I use it I would have to specify a default value for withCredentials.
withCredentials is type of boolean and is optional, see here. With exactOptionalPropertyTypes an assignment of undefined wouldn't be allowed.
withCredentials: withCredentials ?? false seemed more like a breaking change
There was a problem hiding this comment.
But I would be fine to go this route. I had a rough look at the Angular code and it seems that no distinction is made between undefined and false.
| if (configurationParameters.encodeParam) { | ||
| this.encodeParam = configurationParameters.encodeParam; | ||
| constructor({ accessToken, apiKeys, basePath, credentials, encodeParam, encoder, password, username, withCredentials }: {{configurationParametersInterfaceName}} = {}) { | ||
| if (apiKeys) { |
There was a problem hiding this comment.
These are all guarded now, but beforehand they weren't, if the containing object was truthy all of them would have been set, no matter if truthy or not. Do we need to look into it in more detail on whether that behavior changes are fully backwards compatible?
There was a problem hiding this comment.
That is absolutely correct. I have adapted it by explicitly checking for undefined. The only exceptions are encoder and apiKeys, as both can only be of data type truthy or undefined.
…lar-exactOptionalPropertyTypes
fixes #20450
PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master(upcoming7.x.0minor release - breaking changes with fallbacks),8.0.x(breaking changes without fallbacks)@TiFu (2017/07) @taxpon (2017/07) @sebastianhaas (2017/07) @kenisteward (2017/07) @Vrolijkx (2017/09) @macjohnny (2018/01) @topce (2018/10) @akehir (2019/07) @petejohansonxo (2019/11) @amakhrov (2020/02) @davidgamero (2022/03) @mkusaka (2022/04) @joscha (2024/10)