CompiledName attribute not working for union type members
See original GitHub issueGenerated union types currently contain members with different casing than the original enums.
Problem is that CompiledName attribute does not work with members of union type. It works with values and functions.
Example
Following code shows that value of PPA generates a property Ppa which causes a problem during the runtime.
enum MyEnumType { Shopping PPA }
produces
type ProductLabelDomainType = | [<CompiledName "Shopping">] Shopping | [<CompiledName "PPA">] Ppa
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Typescript: check for intersections between union types ...
Typescript: check for intersections between union types, ensure all members are unique - Stack Overflow.
Read more >Erased type-tagged anonymous union types · Issue #538
I propose we add erased union types as an F# first citizen. ... (Note using a struct union would not work well as...
Read more >Handbook - Unions and Intersection Types
Unions with Common Fields If we have a value that is a union type, we can only access members that are common to...
Read more >F# Interop with Javascript in Fable: The Complete Guide
This is an attribute that you can attach to values, functions, members and other language constructs to override their default code generation. Next...
Read more >Better Typed than Sorry
Precisely, because overloads are not supported in JS, TypeScript often uses what we call erased unions (to tell them apart from actual F#...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@petrkoutnycz unfortunately, GraphQL enums are not always valid as union case names by default. For example, they could be lower-case.
Until I’ve figured out why the serializers are failing in runtime, I’ve added a boolean option called
normalizeEnumCaseswhich is set totrueby default (preserving current behavior) that determines whether changes to enum values should applied. To fix your issue, set this option tofalsein yoursnowflaqe.json:The JSON serializers at runtime know about
CompiledNameand it should work fine.Are you targeting F# on dotnet or Fable?
Is your generated type missing
[<Fable.Core.StringEnum>]? It should be there.I will need more information in order to debug your issue. Snowflaqe config, JSON returned from the GraphQL API, the runtime error you are getting and how the GraphQL schema looks like.