Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Shared.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ module JsonItems =
| Indexer
| SignatureOverload
| TypeDef
| Extends
override x.ToString() = (unionToString x).ToLower()

let findItem (allItems: ItemsType.Root []) (itemName: string) (kind: ItemKind) otherFilter =
Expand Down
11 changes: 9 additions & 2 deletions TS.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,15 @@ let EmitNamedConstructors () =

let EmitInterfaceDeclaration (i:Browser.Interface) =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this only works with interfaces. Is there a need for classes too? (I'm not familiar with lib.d.ts so could be there's not.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no classes in dom.generated.d.ts, all types in the spec translate to an interface (instance side) and a declared var constructor function (static side).

Pt.printl "interface %s" i.Name
match i.Extends::(List.ofArray i.Implements) with
| [""] | [] | ["Object"] -> ()
let extendsFromSpec =
match i.Extends::(List.ofArray i.Implements) with
| [""] | [] | ["Object"] -> []
| specExtends -> specExtends
let extendsFromJson =
JsonItems.getAddedItemsByInterfaceName ItemKind.Extends Flavor.All i.Name
|> Array.map (fun e -> e.BaseInterface.Value) |> List.ofArray
match List.concat [extendsFromSpec; extendsFromJson] with
| [] -> ()
| allExtends -> Pt.print " extends %s" (String.Join(", ", allExtends))
Pt.print " {"

Expand Down
5 changes: 5 additions & 0 deletions inputfiles/sample.json
Original file line number Diff line number Diff line change
Expand Up @@ -330,5 +330,10 @@
"kind": "typedef",
"name": "IDBValidKey",
"type": "number | string | Date | IDBArrayKey"
},
{
"kind": "extends",
"baseInterface": "ParentNode",
"interface": "Document"
}
]