[typescript] fix: escaped multiline comments; implementation option 2
alternative implementation for #19528, via https://github.com/OpenAPITools/openapi-generator/pull/19528#issuecomment-2337016513:
if it's not a lot of work, can you please file another PR to add null guards for the typescript generator(s)?
That changes the implementation of escapeUnsafeCharacters for all generators that are currently implemented in a non-null-safe way.
There were two generators that already hard guards for null. Interestingly they return "" instead, most likely to prevent downstream NPEs; see:
- https://github.com/OpenAPITools/openapi-generator/blob/8171648eb4a194c613b87f681f1ebcd1e169b143/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptApolloClientCodegen.java#L1152-L1154
- https://github.com/OpenAPITools/openapi-generator/blob/8171648eb4a194c613b87f681f1ebcd1e169b143/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptClientCodegen.java#L1158-L1160
Please let me know if you'd like to align.
I also changed the generator scaffold to automatically get the null guard.
@wing328 For the record, I am a bit ambivalent about which way is the better implementation. This one seems to produce less generic code, but puts a lot more stress on each generator. For a community project like this, I'd probably go with a solution that takes the onus away from the generator implementations, as it will need less education and increase general stability.