本文整理汇总了TypeScript中base.Models类的典型用法代码示例。如果您正苦于以下问题:TypeScript Models类的具体用法?TypeScript Models怎么用?TypeScript Models使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Models类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: expect
it.skip("have all non-Widget view models from Python in the Models object", () => {
const missing = []
for (const name of core_defaults.all_view_model_names()) {
if (!(name in Models.registered_names())) {
missing.push(name)
}
}
for (const m of missing) {
console.log(`'Models.${m}' not found but there's a Python model '${m}'`)
}
expect(missing.length).to.equal(0)
})
示例2: it
it("have all view models from Python in registered locations", () => {
const registered: {[key: string]: boolean} = {}
for (const name of Models.registered_names()) {
registered[name] = true
}
const missing = []
const all_view_model_names = concat([core_defaults.all_view_model_names(), widget_defaults.all_view_model_names()])
for (const name of all_view_model_names) {
if (!(name in registered)) {
missing.push(name)
}
}
for (const m of missing) {
console.log(`'base.locations["${m}"]' not found but there's a Python model '${m}'`)
}
expect(missing.length).to.equal(0)
})
示例3: constructor
constructor(attrs?: Partial<AnotherModel.Attrs>) {
super(attrs)
}
static initClass(): void {
this.prototype.type = 'AnotherModel'
this.define<AnotherModel.Props>({
bar: [ p.Number, 1 ],
})
}
}
AnotherModel.initClass()
Models.register('AnotherModel', AnotherModel)
namespace SomeModel {
export type Attrs = p.AttrsOf<Props>
export type Props = Model.Props & {
foo: p.Property<number>
child: p.Property<Model | null>
}
}
interface SomeModel extends SomeModel.Attrs {}
class SomeModel extends Model {
properties: SomeModel.Props
constructor(attrs?: Partial<SomeModel.Attrs>) {