• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2* Copyright (c) Microsoft Corporation. All rights reserved.
3* Copyright (c) 2023 Huawei Device Co., Ltd.
4* Licensed under the Apache License, Version 2.0 (the "License");
5* you may not use this file except in compliance with the License.
6* You may obtain a copy of the License at
7*
8*     http://www.apache.org/licenses/LICENSE-2.0
9*
10* Unless required by applicable law or agreed to in writing, software
11* distributed under the License is distributed on an "AS IS" BASIS,
12* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13* See the License for the specific language governing permissions and
14* limitations under the License.
15*
16* This file has been modified by Huawei to verify type inference by adding verification statements.
17*/
18
19// === tests/cases/compiler/genericClassPropertyInheritanceSpecialization.ts ===
20declare function AssertType(value:any, type:string):void;
21interface KnockoutObservableBase<T> {
22    peek(): T;
23    (): T;
24    (value: T): void;
25}
26
27interface KnockoutObservable<T> extends KnockoutObservableBase<T> {
28    equalityComparer(a: T, b: T): boolean;
29    valueHasMutated(): void;
30    valueWillMutate(): void;
31}
32
33interface KnockoutObservableArray<T> extends KnockoutObservable<T[]> {
34    indexOf(searchElement: T, fromIndex?: number): number;
35    slice(start: number, end?: number): T[];
36    splice(start: number, deleteCount?: number, ...items: T[]): T[];
37    pop(): T;
38    push(...items: T[]): void;
39    shift(): T;
40    unshift(...items: T[]): number;
41    reverse(): T[];
42    sort(compareFunction?: (a: T, b: T) => number): void;
43    replace(oldItem: T, newItem: T): void;
44    remove(item: T): T[];
45    removeAll(items?: T[]): T[];
46    destroy(item: T): void;
47    destroyAll(items?: T[]): void;
48}
49
50interface KnockoutObservableArrayStatic {
51    fn: KnockoutObservableArray<any>;
52
53    <T>(value?: T[]): KnockoutObservableArray<T>;
54}
55
56declare module ko {
57    export let observableArray: KnockoutObservableArrayStatic;
58}
59
60module Portal.Controls.Validators {
61
62    export class Validator<TValue> {
63        private _subscription;
64        public message: KnockoutObservable<string>;
65        public validationState: KnockoutObservable<number>;
66        public validate: KnockoutObservable<TValue>;
67        constructor(message?: string) { }
68        public destroy(): void { }
69        public _validate(value: TValue): number {
70AssertType(0, "int");
71return 0
72}
73    }
74}
75
76module PortalFx.ViewModels.Controls.Validators {
77
78    export class Validator<TValue> extends Portal.Controls.Validators.Validator<TValue> {
79
80        constructor(message?: string) {
81            super(message);
82AssertType(super(message), "void");
83AssertType(super, "typeof Portal.Controls.Validators.Validator");
84AssertType(message, "string");
85        }
86    }
87
88}
89
90interface Contract<TValue> {
91
92    validators: KnockoutObservableArray<PortalFx.ViewModels.Controls.Validators.Validator<TValue>>;
93}
94
95
96class ViewModel<TValue> implements Contract<TValue> {
97
98    public validators: KnockoutObservableArray<PortalFx.ViewModels.Controls.Validators.Validator<TValue>> = ko.observableArray<PortalFx.ViewModels.Controls.Validators.Validator<TValue>>();
99}
100
101
102
103