module rec Glutinum
open Fable.Core
open Fable.Core.JsInterop
open System
[<AllowNullLiteral>]
[<Interface>]
type LiteralBool =
abstract member log: bool with get, set
Problem description
TypeScript allows to pass literal values in the type but not F#.
To support this syntax, we currently transform the literal value to its type representation. But this means that people could pass false instead of the only accepted value which is true.
Is there something we can do about that?
Perhaps, we could use Emit to generate on the fly the POJO but is it worth the complexity?
module rec Glutinum
open Fable.Core
open Fable.Core.JsInterop
open System
[<Global>]
[<AllowNullLiteral>]
type options
[<Emit("{name: $0, log: true}")>]
(
name : string,
log: bool
) =
member val log : bool = nativeOnly with get, set
let o = options("maxime", false) // I on purpose used false here to show that the output always use true
generates
export const o = {name: "maxime", log: true};
This is correct but can be confusing for the user.
Issue created from Glutinum Tool
Glutinum version - 0.9.0-preview
TypeScript
FSharp
Problem description
TypeScript allows to pass literal values in the type but not F#.
To support this syntax, we currently transform the literal value to its type representation. But this means that people could pass
false
instead of the only accepted value which istrue
.Is there something we can do about that?
Perhaps, we could use
Emit
to generate on the fly the POJO but is it worth the complexity?generates
This is correct but can be confusing for the user.