When TypeScript enums or union types contain special characters (like @, /, -), Glutinum generates F# identifiers that either need backticks or fail compilation. Better sanitization with [<CompiledName>] would improve ergonomics.
Example (from CloudflareFS Management API generation)
// TypeScript enum with special characters
type VectorizePreset =
| "@cf/baai/bge-small-en-v1.5"
| "openai/text-embedding-ada-002"
Current Behavior (Hawaii, similar pattern)
type VectorizePreset =
| [<CompiledName "@cf/baai/bge-small-en-v1.5">] @cfBaaiBgeSmallEnV1Numeric_5
// ^ Invalid F# identifier starting with @
Proposed Improvement
type VectorizePreset =
| [<CompiledName "@cf/baai/bge-small-en-v1.5">] CfBaaiBgeSmallEnV15
| [<CompiledName "openai/text-embedding-ada-002">] OpenAiTextEmbeddingAda002
Sanitization Rules
- Remove leading special characters
- Convert
/, -, . to word boundaries for PascalCase
- Remove numeric suffixes that can't be in identifiers
- Always use
[<CompiledName>] to preserve original value
CloudflareFS Workaround
Manual post-processing scripts that:
- Detect problematic identifiers
- Add backticks where needed
- Fix pattern matching to use consistent escaping
When TypeScript enums or union types contain special characters (like
@,/,-), Glutinum generates F# identifiers that either need backticks or fail compilation. Better sanitization with[<CompiledName>]would improve ergonomics.Example (from CloudflareFS Management API generation)
Current Behavior (Hawaii, similar pattern)
Proposed Improvement
Sanitization Rules
/,-,.to word boundaries for PascalCase[<CompiledName>]to preserve original valueCloudflareFS Workaround
Manual post-processing scripts that: