Skip to content

Commit 8d5fbfd

Browse files
committed
Merge pull request #20 from Microsoft/addSupportForInterfaceCtors
Add support for constructors in added interface json file
2 parents 5df353c + 46cc620 commit 8d5fbfd

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

TS.fsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,13 +545,20 @@ let EmitAddedInterface (ai: JsonItems.ItemsType.Root) =
545545
match ai.Extends with
546546
| Some e -> Pt.printl "interface %s extends %s {" ai.Name.Value ai.Extends.Value
547547
| None -> Pt.printl "interface %s {" ai.Name.Value
548-
548+
549549
ai.Properties |> Array.iter (fun p -> Pt.printWithAddedIndent "%s: %s;" p.Name p.Type)
550550
ai.Methods |> Array.collect (fun m -> m.Signatures) |> Array.iter (Pt.printWithAddedIndent "%s;")
551551
ai.Indexer |> Array.collect (fun i -> i.Signatures) |> Array.iter (Pt.printWithAddedIndent "%s;")
552552
Pt.printl "}"
553553
Pt.printl ""
554554

555+
if ai.ConstructorSignatures.Length > 0 then
556+
Pt.printl "declare var %s: {" ai.Name.Value
557+
Pt.printWithAddedIndent "prototype: %s;" ai.Name.Value
558+
ai.ConstructorSignatures |> Array.iter (Pt.printWithAddedIndent "%s;")
559+
Pt.printl "}"
560+
Pt.printl ""
561+
555562
let EmitTheWholeThing flavor (target:TextWriter) =
556563
Pt.reset()
557564
Pt.printl "/////////////////////////////"

inputfiles/sample.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@
5353
{
5454
"kind": "interface",
5555
"name": "BlobPropertyBag",
56+
"constructorSignatures": [
57+
"new(): NodeList"
58+
],
5659
"properties": [
5760
{
5861
"name": "type?",

0 commit comments

Comments
 (0)