Skip to content

Commit 87e85b4

Browse files
committed
[WIP] Fable support update
1 parent b82256d commit 87e85b4

File tree

2 files changed

+17
-20
lines changed

2 files changed

+17
-20
lines changed

src/fable/Fable.Core/AST/AST.Babel.fs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ open Fable.AST
1010
/// otherwise it is an object consisting of a start position (the position of the first character of the parsed source region)
1111
/// and an end position (the position of the first character after the parsed source region):
1212
[<AbstractClass>]
13-
type Node(typ, ?loc) =
14-
member x.``type``: string = typ
13+
type Node(``type``, ?loc) =
14+
member x.``type``: string = ``type``
1515
member x.loc: SourceLocation option = loc
1616

1717
/// Since the left-hand side of an assignment may be any expression in general, an expression can also be a pattern.
@@ -28,8 +28,8 @@ type Node(typ, ?loc) =
2828
[<AbstractClass>] type ModuleDeclaration(typ, ?loc) = inherit Node(typ, ?loc = loc)
2929

3030
[<AbstractClass>]
31-
type TypeAnnotationInfo(typ) =
32-
member x.``type``: string = typ
31+
type TypeAnnotationInfo(``type``) =
32+
member x.``type``: string = ``type``
3333

3434
type TypeAnnotation(typeInfo) =
3535
member x.``type`` = "TypeAnnotation"
@@ -277,11 +277,11 @@ type ForOfStatement(left, right, body, ?loc) =
277277
member x.right: Expression = right
278278

279279
/// A function declaration. Note that id cannot be null.
280-
type FunctionDeclaration(id, arguments, body, ?generator, ?async,
280+
type FunctionDeclaration(id, ``params``, body, ?generator, ?async,
281281
?returnType, ?typeParams, ?loc) =
282282
inherit Declaration("FunctionDeclaration", ?loc = loc)
283283
member x.id: Identifier = id
284-
member x.``params``: Pattern list = arguments
284+
member x.``params``: Pattern list = ``params``
285285
member x.body: BlockStatement = body
286286
member x.generator = defaultArg generator false
287287
member x.async = defaultArg async false
@@ -298,19 +298,19 @@ type ThisExpression(?loc) =
298298
inherit Expression("ThisExpression", ?loc = loc)
299299

300300
/// A fat arrow function expression, e.g., let foo = (bar) => { /* body */ }.
301-
type ArrowFunctionExpression(arguments, body, ?async, ?loc) =
301+
type ArrowFunctionExpression(``params``, body, ?async, ?loc) =
302302
inherit Expression("ArrowFunctionExpression", ?loc = loc)
303303
member x.expression =
304304
match body with U2.Case1 _ -> false | U2.Case2 _ -> true
305-
member x.``params``: Pattern list = arguments
305+
member x.``params``: Pattern list = ``params``
306306
member x.body: U2<BlockStatement, Expression> = body
307307
member x.async: bool = defaultArg async false
308308

309-
type FunctionExpression(arguments, body, ?generator, ?async,
309+
type FunctionExpression(``params``, body, ?generator, ?async,
310310
?id, ?returnType, ?typeParams, ?loc) =
311311
inherit Expression("FunctionExpression", ?loc = loc)
312312
member x.id: Identifier option = id
313-
member x.``params``: Pattern list = arguments
313+
member x.``params``: Pattern list = ``params``
314314
member x.body: BlockStatement = body
315315
member x.generator: bool = defaultArg generator false
316316
member x.async: bool = defaultArg async false
@@ -365,13 +365,13 @@ type ObjectProperty(key, value, ?shorthand, ?computed, ?loc) =
365365

366366
type ObjectMethodKind = ObjectGetter | ObjectSetter | ObjectMeth
367367

368-
type ObjectMethod(kind, key, arguments, body, ?computed, ?generator,
368+
type ObjectMethod(kind, key, ``params``, body, ?computed, ?generator,
369369
?async, ?returnType, ?typeParams, ?loc) =
370370
inherit ObjectMember("ObjectMethod", key, ?computed=computed, ?loc=loc)
371371
member x.kind = match kind with ObjectGetter -> "get"
372372
| ObjectSetter -> "set"
373373
| ObjectMeth -> "method"
374-
member x.``params``: Pattern list = arguments
374+
member x.``params``: Pattern list = ``params``
375375
member x.body: BlockStatement = body
376376
member x.generator: bool = defaultArg generator false
377377
member x.async: bool = defaultArg async false
@@ -527,15 +527,15 @@ type RestElement(argument, ?loc) =
527527
type ClassMethodKind =
528528
| ClassConstructor | ClassFunction | ClassGetter | ClassSetter
529529

530-
type ClassMethod(kind, key, args, body, computed, ``static``,
530+
type ClassMethod(kind, key, ``params``, body, computed, ``static``,
531531
?returnType, ?typeParams, ?loc) =
532532
inherit Node("ClassMethod", ?loc = loc)
533533
member x.kind = match kind with ClassConstructor -> "constructor"
534534
| ClassGetter -> "get"
535535
| ClassSetter -> "set"
536536
| ClassFunction -> "method"
537537
member x.key: Expression = key
538-
member x.``params``: Pattern list = args
538+
member x.``params``: Pattern list = ``params``
539539
member x.body: BlockStatement = body
540540
member x.computed: bool = computed
541541
member x.``static``: bool = ``static``
@@ -665,9 +665,9 @@ type FunctionTypeParam(name, typeInfo, ?optional) =
665665
member x.typeAnnotation: TypeAnnotationInfo = typeInfo
666666
member x.optional = defaultArg optional false
667667

668-
type FunctionTypeAnnotation(args, returnType, ?rest) =
668+
type FunctionTypeAnnotation(``params``, returnType, ?rest) =
669669
inherit TypeAnnotationInfo("FunctionTypeAnnotation")
670-
member x.``params``: FunctionTypeParam list = args
670+
member x.``params``: FunctionTypeParam list = ``params``
671671
member x.rest: FunctionTypeParam option = rest
672672
member x.returnType: TypeAnnotationInfo = returnType
673673

src/netcore/Fable.Client.Browser/demo/repl.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -331,10 +331,7 @@
331331
v.Fields.length == 1 ? v.Fields[0] : v.Fields.length > 1 ? v.Fields : v.Case
332332
: (k.startsWith("directives@") || k.startsWith("specifiers@")) && !v ? [] : v;
333333
};
334-
let astJson = JSON.stringify(ast, fixValue)
335-
.replace(/"typ":/g, '"type":')
336-
.replace(/@[0-9]+"/g, '"')
337-
.replace(/"args":/g, '"params":');
334+
let astJson = JSON.stringify(ast, fixValue).replace(/@[0-9]+"/g, '"');
338335
let newAst = JSON.parse(astJson);
339336
return newAst;
340337
}

0 commit comments

Comments
 (0)