When targeting Typescript mutable fields on structs cause the struct to be wraped in FSharpRef<_> , but then the access to the field fails to compile
This happens only when there is mutable after val
[<Struct>]
type R =
val mutable X: float
new(x: float) = { X = x }
member this.IsEmpty() =
// emits invalid TS
// Property 'X' does not exist on type 'FSharpRef<Rt>'.
this.X < 0.0
compiles to
export class R extends Record implements IEquatable<R>, IComparable<R> {
X: float64;
constructor(X: float64) {
super();
this.X = X;
}
}
export function R__IsEmpty(this$: FSharpRef<R>): boolean {
return this$.X < 0; // Property 'X' does not exist on type 'FSharpRef<Rt>'.
}
why is FSharpRef<_> needed here?
Tested on 5.rc5 and in REPL
When targeting Typescript mutable fields on structs cause the struct to be wraped in FSharpRef<_> , but then the access to the field fails to compile
This happens only when there is
mutableaftervalcompiles to
why is
FSharpRef<_>needed here?Tested on 5.rc5 and in REPL