Skip to content

Commit 5c03eed

Browse files
authored
Update documentation
taken from fable-compiler/Fable#2253
1 parent 24a5d4f commit 5c03eed

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

docs/docs/javascript/compatibility.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,3 +229,31 @@ The resulting printed list of pseudo-random numbers does not work in Fable:
229229

230230
* When accurate low-order bit arithmetic is needed and overflow can result in numbers larger than 2^53 use `int64`, `uint64`, which use exact 64 bits, instead of `int32`, `uint32`.
231231
* Alternately, truncate all arithmetic with `>>> 0` or `>>> 0u` as appropriate before numbers can get larger than 2^53: `let rng (s:int32) = 10001*s + 12345 >>> 0`
232+
233+
## Unsupported Attributes and Types
234+
235+
If your F# code contains attributes (or other types) that are not supported by Fable you will get a Compiler error similar to:
236+
` error FSHARP: The type 'DataContract' is not defined. (code 39)`
237+
for
238+
```fsharp
239+
open System.Runtime.Serialization
240+
[<DataContract>]
241+
type Person = {
242+
[<DataMember(IsRequired = true)>] FullName: string
243+
[<DataMember(IsRequired = true)>] TimeOfBirth: DateTimeOffset
244+
}
245+
```
246+
247+
If you just want the attribute (or types) to be ignored in Fable you can redefine it as an empty type:
248+
249+
```fsharp
250+
#if FABLE_COMPILER
251+
namespace System.Runtime.Serialization
252+
open System
253+
type DataContract() = inherit Attribute()
254+
type DataMember(IsRequired: bool) = inherit Attribute()
255+
#endif
256+
```
257+
258+
259+

0 commit comments

Comments
 (0)