@@ -79,13 +79,13 @@ let rec DomTypeToTsType (objDomType: string) =
79
79
else " any"
80
80
81
81
let EmitConstants ( i : Browser.Interface ) =
82
- let emitConstantFromJson ( c : ItemsType.Root ) = Pt.printl " %s : %s ;" c.Name.Value c.Type.Value
82
+ let emitConstantFromJson ( c : ItemsType.Root ) = Pt.printl " readonly %s : %s ;" c.Name.Value c.Type.Value
83
83
84
84
let emitConstant ( c : Browser.Constant ) =
85
85
if Option.isNone ( findRemovedItem c.Name ItemKind.Constant i.Name) then
86
86
match findOverriddenItem c.Name ItemKind.Constant i.Name with
87
87
| Some c' -> emitConstantFromJson c'
88
- | None -> Pt.printl " %s : %s ;" c.Name ( DomTypeToTsType c.Type)
88
+ | None -> Pt.printl " readonly %s : %s ;" c.Name ( DomTypeToTsType c.Type)
89
89
90
90
// Emit the constants added in the json files
91
91
@@ -212,7 +212,11 @@ let EmitEnums () =
212
212
213
213
let EmitProperties flavor prefix ( emitScope : EmitScope ) ( i : Browser.Interface )=
214
214
let emitPropertyFromJson ( p : ItemsType.Root ) =
215
- Pt.printl " %s%s : %s ;" prefix p.Name.Value p.Type.Value
215
+ let readOnlyModifier =
216
+ match p.Readonly with
217
+ | Some( true ) -> " readonly "
218
+ | _ -> " "
219
+ Pt.printl " %s%s%s : %s ;" prefix readOnlyModifier p.Name.Value p.Type.Value
216
220
217
221
let emitProperty ( p : Browser.Property ) =
218
222
match GetCommentForProperty i.Name p.Name with
@@ -227,7 +231,8 @@ let EmitProperties flavor prefix (emitScope: EmitScope) (i: Browser.Interface)=
227
231
match p.Type with
228
232
| " EventHandler" -> String.Format( " (ev: {0}) => any" , ehNameToEType.[ p.Name])
229
233
| _ -> DomTypeToTsType p.Type
230
- Pt.printl " %s%s : %s ;" prefix p.Name pType
234
+ let readOnlyModifier = if p.ReadOnly.IsSome && prefix = " " then " readonly " else " "
235
+ Pt.printl " %s%s%s : %s ;" prefix readOnlyModifier p.Name pType
231
236
232
237
// Note: the schema file shows the property doesn't have "static" attribute,
233
238
// therefore all properties are emited for the instance type.
0 commit comments