本文整理汇总了TypeScript中core/has_props.HasProps类的典型用法代码示例。如果您正苦于以下问题:TypeScript HasProps类的具体用法?TypeScript HasProps怎么用?TypeScript HasProps使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HasProps类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: json
json(references: References): DocumentChanged {
if (this.attr === "id") {
throw new Error("'id' field should never change, whatever code just set it is wrong")
}
if (this.hint != null)
return this.hint.json(references)
const value = this.new_
const value_json = HasProps._value_to_json(this.attr, value, this.model)
const value_refs: {[key: string]: any} = {}
HasProps._value_record_references(value, value_refs, true) // true = recurse
if (this.model.id in value_refs && this.model !== value) {
// we know we don't want a whole new copy of the obj we're
// patching unless it's also the value itself
delete value_refs[this.model.id]
}
for (const id in value_refs) {
references[id] = value_refs[id]
}
return {
kind: "ModelChanged",
model: this.model.ref(),
attr: this.attr,
new: value_json,
}
}
示例2: _value_to_json
static _value_to_json(key, value, optional_parent_object) {
if (isObject(value) && (key === 'data')) {
return serialization.encode_column_data(value, optional_parent_object._shapes)
} else {
return HasProps._value_to_json(key, value, optional_parent_object)
}
}
示例3: _value_to_json
static _value_to_json(key: string, value: any, optional_parent_object: any): any {
if (isPlainObject(value) && key === 'data')
return encode_column_data(value as any, optional_parent_object._shapes) // XXX: unknown vs. any
else
return HasProps._value_to_json(key, value, optional_parent_object)
}