本文整理匯總了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>) {