• 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/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts ===
20declare function AssertType(value:any, type:string):void;
21
22type T1 = { a: number };
23type T2 = T1 & { b: number };
24type T3 = () => void;
25type T4 = new () => { a: number };
26type T5 = number[];
27type T6 = [string, number];
28type T7 = { [P in 'a' | 'b' | 'c']: string };
29
30interface I1 extends T1 { x: string }
31interface I2 extends T2 { x: string }
32interface I3 extends T3 { x: string }
33interface I4 extends T4 { x: string }
34interface I5 extends T5 { x: string }
35interface I6 extends T6 { x: string }
36interface I7 extends T7 { x: string }
37
38type Constructor<T> = new () => T;
39declare function Constructor<T>(): Constructor<T>;
40
41class C1 extends Constructor<I1>() { x: string }
42class C2 extends Constructor<I2>() { x: string }
43class C3 extends Constructor<I3>() { x: string }
44class C4 extends Constructor<I4>() { x: string }
45class C5 extends Constructor<I5>() { x: string }
46class C6 extends Constructor<I6>() { x: string }
47class C7 extends Constructor<I7>() { x: string }
48
49declare function fx(x: string): string;
50declare class CX { a: number }
51declare enum EX { A, B, C }
52declare namespace NX { export const a = 1 }
53
54type T10 = typeof fx;
55type T11 = typeof CX;
56type T12 = typeof EX;
57type T13 = typeof NX;
58
59interface I10 extends T10 { x: string }
60interface I11 extends T11 { x: string }
61interface I12 extends T12 { x: string }
62interface I13 extends T13 { x: string }
63
64type Identifiable<T> = { _id: string } & T;
65
66interface I20 extends Partial<T1> { x: string }
67interface I21 extends Readonly<T1> { x: string }
68interface I22 extends Identifiable<T1> { x: string }
69interface I23 extends Identifiable<T1 & { b: number}> { x: string }
70
71class C20 extends Constructor<Partial<T1>>() { x: string }
72class C21 extends Constructor<Readonly<T1>>() { x: string }
73class C22 extends Constructor<Identifiable<T1>>() { x: string }
74class C23 extends Constructor<Identifiable<T1 & { b: number}>>() { x: string }
75
76
77