Skip to content

Commit de596be

Browse files
committed
Detect changes in json files regarding dictionary types
1 parent 3ee89b9 commit de596be

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

TS.fsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,8 +531,25 @@ let EmitDictionaries flavor =
531531
| "Object" -> Pt.printl "interface %s {" dict.Name
532532
| _ -> Pt.printl "interface %s extends %s {" dict.Name dict.Extends
533533

534+
let emitJsonProperty (p: ItemsType.Root) =
535+
Pt.printl "%s: %s;" p.Name.Value p.Type.Value
536+
537+
let removedPropNames =
538+
getRemovedItems ItemKind.Property flavor
539+
|> Array.filter (matchInterface dict.Name)
540+
|> Array.map (fun rp -> rp.Name.Value)
541+
let addedProps =
542+
getAddedItems ItemKind.Property flavor
543+
|> Array.filter (matchInterface dict.Name)
544+
534545
Pt.increaseIndent()
535-
dict.Members |> Array.iter (fun m -> Pt.printl "%s?: %s;" m.Name (DomTypeToTsType m.Type))
546+
Array.iter emitJsonProperty addedProps
547+
dict.Members
548+
|> Array.filter (fun m -> not (Array.contains m.Name removedPropNames))
549+
|> Array.iter (fun m ->
550+
match (findOverriddenItem m.Name ItemKind.Property dict.Name) with
551+
| Some om -> emitJsonProperty om
552+
| None -> Pt.printl "%s?: %s;" m.Name (DomTypeToTsType m.Type))
536553
Pt.decreaseIndent()
537554
Pt.printl "}"
538555
Pt.printl ""

0 commit comments

Comments
 (0)