fix(typescript): keep non-latin letters in enum keys
toEnumVarName in AbstractTypeScriptClientCodegen strips chars with ASCII \W, so enum values like À, Москва or 日本語 end up with empty key and generated code is { : 'À' }, which is TS1136 in every typescript-* generator with default settings
Now if nothing is left after sanitizeName, value is sanitized again with unicode (?U)\W, so Москва gives Москва: 'Москва'
I know allowUnicodeIdentifiers exists and gives valid output, but default output should not be invalid TypeScript. Only keys that are empty today change, anything that already produced non-empty key is untouchd (Café is still Caf, Москва 2 is still _2). Same idea as #24427, default sanitization fixed in this class without new option
Added test with À, Москва and Нур-Султан in TypeScriptAngularClientCodegenTest, it fails on master (expected [À] but found [])
Full ./mvnw clean package passes apart from Kotlin tests (embedded Kotlin compiler fails on my JDK 25). Regenerated all 93 bin/configs/typescript*.yaml, no sample changes. Did not run other configs, only typescript abstract class is touched. Generated typescript-angular and typescript-fetch for a spec with À and Москва enums pass tsc --strict, typescript-axios has no syntax errors (only missing axios module in my scratch dir)
This is typescript part of #16928, dart part is not touched
Fixes #9739
PR checklist
- Read the contribution guidelines.
- Run the following to build the project and update samples:
Commit all changed files../mvnw clean package || exit ./bin/generate-samples.sh ./bin/configs/*.yaml || exit ./bin/utils/export_docs_generators.sh || exit - If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.
@TiFu @taxpon @sebastianhaas @kenisteward @Vrolijkx @macjohnny @topce @akehir @petejohansonxo @amakhrov @davidgamero @mkusaka @joscha @KannaKim
Summary by cubic
Fixes toEnumVarName in AbstractTypeScriptClientCodegen so enum values containing only non-Latin characters no longer produce invalid TypeScript like { : 'Москва' }.
- When ASCII sanitization strips everything, the value is re-sanitized with a Unicode-aware pattern, keeping letters such as
À,Москва, orНур-Султан. - Values that already produce a non-empty key are unchanged (
Caféstill becomesCaf). - Adds tests for non-Latin enum values in
TypeScriptAngularClientCodegenTestand fixes #9739.