Generated tests for erased unions not working with Fable 2
See original GitHub issuePeople are reporting that the automatically generated tests for erased unions are not compiling in Fable 2. See: https://github.com/fable-compiler/Fable/issues/1580#issuecomment-428425911
For example:
type VerifyErrors =
U3<JsonWebTokenError, NotBeforeError, TokenExpiredError>
module VerifyErrors =
let isJsonWebTokenError (v: VerifyErrors) = match v with U3.Case1 _ -> true | _ -> false
The problem is not the erased union, but JsonWebTokenError
. ts2fable generates types as interfaces and Fable 2 is throwing a compile error if trying to type test against an interface because it doesn’t know how to identify the interface. Fable 1 added the interface name to types coming from F#, but this didn’t work with JS objects, so we’ve opted to be more strict in Fable 2 and avoid unexpected behaviour at runtime.
Should we stop generating these automatic matches?
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Can't type tests interfaces in Fable 2 · Issue #1580
Description Can't match erased types in Fable 2.0.0 (worked in Fable 1). ... Generated tests for erased unions not working with Fable 2...
Read more >Better Typed than Sorry
Erased unions #. Precisely, because overloads are not supported in JS, TypeScript often uses what we call erased unions (to tell them apart...
Read more >Interacting with JavaScript - F# |> BABEL
Fable allows the same feature by using union types and the StringEnum attribute. These union types must not have any data fields as...
Read more >Fable 2 is Better Than Fable 3 - YouTube
I did a video exploring the shortcomings of Fable 3 recently, I thought why not do a follow up video discussing the game...
Read more >Keeping models in sync with Reinforced.Typings
Keeping types in sync between the server and the frontend has long been a sticking point in my development career. It gives me...
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
You should delete
And others things that are looking similar to that.
I think they still work indeed because they don’t “type check against an interface”