mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
120 lines
3.6 KiB
TypeScript
120 lines
3.6 KiB
TypeScript
//// [tests/cases/compiler/genericClassPropertyInheritanceSpecialization.ts] ////
|
|
|
|
//// [genericClassPropertyInheritanceSpecialization.ts]
|
|
interface KnockoutObservableBase<T> {
|
|
peek(): T;
|
|
(): T;
|
|
(value: T): void;
|
|
}
|
|
|
|
interface KnockoutObservable<T> extends KnockoutObservableBase<T> {
|
|
equalityComparer(a: T, b: T): boolean;
|
|
valueHasMutated(): void;
|
|
valueWillMutate(): void;
|
|
}
|
|
|
|
interface KnockoutObservableArray<T> extends KnockoutObservable<T[]> {
|
|
indexOf(searchElement: T, fromIndex?: number): number;
|
|
slice(start: number, end?: number): T[];
|
|
splice(start: number, deleteCount?: number, ...items: T[]): T[];
|
|
pop(): T;
|
|
push(...items: T[]): void;
|
|
shift(): T;
|
|
unshift(...items: T[]): number;
|
|
reverse(): T[];
|
|
sort(compareFunction?: (a: T, b: T) => number): void;
|
|
replace(oldItem: T, newItem: T): void;
|
|
remove(item: T): T[];
|
|
removeAll(items?: T[]): T[];
|
|
destroy(item: T): void;
|
|
destroyAll(items?: T[]): void;
|
|
}
|
|
|
|
interface KnockoutObservableArrayStatic {
|
|
fn: KnockoutObservableArray<any>;
|
|
|
|
<T>(value?: T[]): KnockoutObservableArray<T>;
|
|
}
|
|
|
|
declare namespace ko {
|
|
export var observableArray: KnockoutObservableArrayStatic;
|
|
}
|
|
|
|
namespace Portal.Controls.Validators {
|
|
|
|
export class Validator<TValue> {
|
|
private _subscription;
|
|
public message: KnockoutObservable<string>;
|
|
public validationState: KnockoutObservable<number>;
|
|
public validate: KnockoutObservable<TValue>;
|
|
constructor(message?: string) { }
|
|
public destroy(): void { }
|
|
public _validate(value: TValue): number {return 0 }
|
|
}
|
|
}
|
|
|
|
namespace PortalFx.ViewModels.Controls.Validators {
|
|
|
|
export class Validator<TValue> extends Portal.Controls.Validators.Validator<TValue> {
|
|
|
|
constructor(message?: string) {
|
|
super(message);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
interface Contract<TValue> {
|
|
|
|
validators: KnockoutObservableArray<PortalFx.ViewModels.Controls.Validators.Validator<TValue>>;
|
|
}
|
|
|
|
|
|
class ViewModel<TValue> implements Contract<TValue> {
|
|
|
|
public validators: KnockoutObservableArray<PortalFx.ViewModels.Controls.Validators.Validator<TValue>> = ko.observableArray<PortalFx.ViewModels.Controls.Validators.Validator<TValue>>();
|
|
}
|
|
|
|
|
|
|
|
//// [genericClassPropertyInheritanceSpecialization.js]
|
|
"use strict";
|
|
var Portal;
|
|
(function (Portal) {
|
|
var Controls;
|
|
(function (Controls) {
|
|
var Validators;
|
|
(function (Validators) {
|
|
class Validator {
|
|
constructor(message) { }
|
|
destroy() { }
|
|
_validate(value) { return 0; }
|
|
}
|
|
Validators.Validator = Validator;
|
|
})(Validators = Controls.Validators || (Controls.Validators = {}));
|
|
})(Controls = Portal.Controls || (Portal.Controls = {}));
|
|
})(Portal || (Portal = {}));
|
|
var PortalFx;
|
|
(function (PortalFx) {
|
|
var ViewModels;
|
|
(function (ViewModels) {
|
|
var Controls;
|
|
(function (Controls) {
|
|
var Validators;
|
|
(function (Validators) {
|
|
class Validator extends Portal.Controls.Validators.Validator {
|
|
constructor(message) {
|
|
super(message);
|
|
}
|
|
}
|
|
Validators.Validator = Validator;
|
|
})(Validators = Controls.Validators || (Controls.Validators = {}));
|
|
})(Controls = ViewModels.Controls || (ViewModels.Controls = {}));
|
|
})(ViewModels = PortalFx.ViewModels || (PortalFx.ViewModels = {}));
|
|
})(PortalFx || (PortalFx = {}));
|
|
class ViewModel {
|
|
constructor() {
|
|
this.validators = ko.observableArray();
|
|
}
|
|
}
|