-
Notifications
You must be signed in to change notification settings - Fork 304
/
Fable.Core.fs
141 lines (118 loc) · 4.72 KB
/
Fable.Core.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
namespace Fable.Core
open System
[<AutoOpen>]
module Exceptions =
/// Used to indicate that a member is only implemented in native Javascript
let jsNative<'T> : 'T = failwith "JS only"
/// Used for erased union types and to ignore modules in JS compilation.
/// More info: http://fable.io/docs/interacting.html#Erase-attribute
type EraseAttribute() =
inherit Attribute()
/// The module, type, function... is globally accessible in JS.
/// More info: http://fable.io/docs/interacting.html#Import-attribute
type GlobalAttribute() =
inherit Attribute()
new (name: string) = GlobalAttribute()
/// References to the module, type, function... will be replaced by import statements.
/// Use `[<Import("default", "my-package")>] to import the default member.
/// Use `[<Import("*", "my-package")>] to import the whole package.
/// More info: http://fable.io/docs/interacting.html#Import-attribute
type ImportAttribute(selector: string, from: string) =
inherit Attribute()
/// Function calls will be replaced by inlined JS code.
/// More info: http://fable.io/docs/interacting.html#Import-attribute
type EmitAttribute private () =
inherit Attribute()
new (macro: string) = EmitAttribute()
new (emitterType: Type, methodName: string) = EmitAttribute()
new (emitterType: Type, methodName: string, extraArg: string) = EmitAttribute()
/// When this is attached to a method, Fable will add the generic info
/// as an extra argument to every call, making it possible to access
/// a type 'T with `typeof<'T>` within the method body
[<AttributeUsage(AttributeTargets.Method)>]
type PassGenericsAttribute() =
inherit Attribute()
/// Compile a record as a JS object literals.
/// More info: http://fable.io/docs/interacting.html
type PojoAttribute() =
inherit Attribute()
/// Compile union types as string literals.
/// More info: http://fable.io/docs/interacting.html#StringEnum-attribute
[<AttributeUsage(AttributeTargets.Class)>]
type StringEnumAttribute() =
inherit Attribute()
/// Erased union type to represent one of two possible values.
/// More info: http://fable.io/docs/interacting.html#Erase-attribute
type [<Erase>] U2<'a, 'b> =
| Case1 of 'a
| Case2 of 'b
static member op_ErasedCast(x:'a) = Case1 x
static member op_ErasedCast(x:'b) = Case2 x
/// Erased union type to represent one of three possible values.
/// More info: http://fable.io/docs/interacting.html#Erase-attribute
type [<Erase>] U3<'a, 'b, 'c> =
| Case1 of 'a
| Case2 of 'b
| Case3 of 'c
static member op_ErasedCast(x:'a) = Case1 x
static member op_ErasedCast(x:'b) = Case2 x
static member op_ErasedCast(x:'c) = Case3 x
/// Erased union type to represent one of four possible values.
/// More info: http://fable.io/docs/interacting.html#Erase-attribute
type [<Erase>] U4<'a, 'b, 'c, 'd> =
| Case1 of 'a
| Case2 of 'b
| Case3 of 'c
| Case4 of 'd
static member op_ErasedCast(x:'a) = Case1 x
static member op_ErasedCast(x:'b) = Case2 x
static member op_ErasedCast(x:'c) = Case3 x
static member op_ErasedCast(x:'d) = Case4 x
/// Erased union type to represent one of five possible values.
/// More info: http://fable.io/docs/interacting.html#Erase-attribute
type [<Erase>] U5<'a, 'b, 'c, 'd, 'e> =
| Case1 of 'a
| Case2 of 'b
| Case3 of 'c
| Case4 of 'd
| Case5 of 'e
static member op_ErasedCast(x:'a) = Case1 x
static member op_ErasedCast(x:'b) = Case2 x
static member op_ErasedCast(x:'c) = Case3 x
static member op_ErasedCast(x:'d) = Case4 x
static member op_ErasedCast(x:'e) = Case5 x
/// Erased union type to represent one of six possible values.
/// More info: http://fable.io/docs/interacting.html#Erase-attribute
type [<Erase>] U6<'a, 'b, 'c, 'd, 'e, 'f> =
| Case1 of 'a
| Case2 of 'b
| Case3 of 'c
| Case4 of 'd
| Case5 of 'e
| Case6 of 'f
static member op_ErasedCast(x:'a) = Case1 x
static member op_ErasedCast(x:'b) = Case2 x
static member op_ErasedCast(x:'c) = Case3 x
static member op_ErasedCast(x:'d) = Case4 x
static member op_ErasedCast(x:'e) = Case5 x
static member op_ErasedCast(x:'f) = Case6 x
/// DO NOT USE: Internal type for Fable dynamic operations
type Applicable = obj->obj
type CaseRules =
| None = 0
| LowerFirst = 1
module Testing =
type TestAttribute() =
inherit Attribute()
type TestFixtureAttribute() =
inherit Attribute()
type TestFixtureSetUpAttribute() =
inherit Attribute()
type TestFixtureTearDownAttribute() =
inherit Attribute()
type SetUpAttribute() =
inherit Attribute()
type TearDownAttribute() =
inherit Attribute()
type Assert =
static member AreEqual(expected: 'T, actual: 'T, ?msg: string): unit = jsNative