From 46cc620298d99aeedbdb6b9b8496e27d031eca8c Mon Sep 17 00:00:00 2001 From: zhengbli Date: Tue, 10 Nov 2015 15:22:06 -0800 Subject: [PATCH] Add support for constructors in added interface json file --- TS.fsx | 9 ++++++++- inputfiles/sample.json | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/TS.fsx b/TS.fsx index c98974df0..535ad7198 100644 --- a/TS.fsx +++ b/TS.fsx @@ -545,13 +545,20 @@ let EmitAddedInterface (ai: JsonItems.ItemsType.Root) = match ai.Extends with | Some e -> Pt.printl "interface %s extends %s {" ai.Name.Value ai.Extends.Value | None -> Pt.printl "interface %s {" ai.Name.Value - + ai.Properties |> Array.iter (fun p -> Pt.printWithAddedIndent "%s: %s;" p.Name p.Type) ai.Methods |> Array.collect (fun m -> m.Signatures) |> Array.iter (Pt.printWithAddedIndent "%s;") ai.Indexer |> Array.collect (fun i -> i.Signatures) |> Array.iter (Pt.printWithAddedIndent "%s;") Pt.printl "}" Pt.printl "" + if ai.ConstructorSignatures.Length > 0 then + Pt.printl "declare var %s: {" ai.Name.Value + Pt.printWithAddedIndent "prototype: %s;" ai.Name.Value + ai.ConstructorSignatures |> Array.iter (Pt.printWithAddedIndent "%s;") + Pt.printl "}" + Pt.printl "" + let EmitTheWholeThing flavor (target:TextWriter) = Pt.reset() Pt.printl "/////////////////////////////" diff --git a/inputfiles/sample.json b/inputfiles/sample.json index 1286731c8..ed0e2ef43 100644 --- a/inputfiles/sample.json +++ b/inputfiles/sample.json @@ -53,6 +53,9 @@ { "kind": "interface", "name": "BlobPropertyBag", + "constructorSignatures": [ + "new(): NodeList" + ], "properties": [ { "name": "type?",