Created
March 3, 2018 23:44
-
-
Save rrdelaney/f93da5d17ccf224c6da0c86999222fe5 to your computer and use it in GitHub Desktop.
TypeScript Decoder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Decoder = { | |
let node = json => { | |
let syntaxKind = json |> Json.Decode.field("kind", Json.Decode.int); | |
if (syntaxKind == Internal.SyntaxKind.declareKeyword) { | |
Unknown; | |
} else { | |
Unknown; | |
}; | |
} | |
and declareKeyword = json => | |
DeclareKeyword( | |
Json.Decode.{ | |
pos: json |> field("pos", int), | |
end_: json |> field("end", int) | |
} | |
) | |
and exportKeyword = json => | |
ExportKeyword( | |
Json.Decode.{ | |
pos: json |> field("pos", int), | |
end_: json |> field("end", int) | |
} | |
) | |
and identifier = json => | |
Identifier( | |
Json.Decode.{ | |
pos: json |> field("pos", int), | |
end_: json |> field("end", int), | |
escapedText: json |> field("escapedText", string), | |
text: json |> field("text", string) | |
} | |
) | |
and functionDeclaration = json => | |
FunctionDeclaration( | |
Json.Decode.{ | |
pos: json |> field("pos", int), | |
end_: json |> field("end", int), | |
modifiers: json |> field("modifiers", array(node)), | |
name: json |> field("name", node), | |
typeParameters: json |> field("typeParameters", array(node)), | |
parameters: json |> field("parameters", array(node)), | |
type_: json |> field("type", node) | |
} | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment