• 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/commentsClass.ts ===
20declare function AssertType(value:any, type:string):void;
21/** This is class c2 without constuctor*/
22class c2 {
23} // trailing comment1
24let i2 = new c2();
25AssertType(i2, "c2");
26AssertType(new c2(), "c2");
27AssertType(c2, "typeof c2");
28
29let i2_c = c2;
30AssertType(i2_c, "typeof c2");
31AssertType(c2, "typeof c2");
32
33class c3 {
34    /** Constructor comment*/
35    constructor() {
36    } // trailing comment of constructor
37} /* trailing comment 2 */
38let i3 = new c3();
39AssertType(i3, "c3");
40AssertType(new c3(), "c3");
41AssertType(c3, "typeof c3");
42
43let i3_c = c3;
44AssertType(i3_c, "typeof c3");
45AssertType(c3, "typeof c3");
46
47/** Class comment*/
48class c4 {
49    /** Constructor comment*/
50    constructor() {
51    } /* trailing comment of constructor 2*/
52}
53let i4 = new c4();
54AssertType(i4, "c4");
55AssertType(new c4(), "c4");
56AssertType(c4, "typeof c4");
57
58let i4_c = c4;
59AssertType(i4_c, "typeof c4");
60AssertType(c4, "typeof c4");
61
62/** Class with statics*/
63class c5 {
64    static s1: number;
65}
66let i5 = new c5();
67AssertType(i5, "c5");
68AssertType(new c5(), "c5");
69AssertType(c5, "typeof c5");
70
71let i5_c = c5;
72AssertType(i5_c, "typeof c5");
73AssertType(c5, "typeof c5");
74
75/// class with statics and constructor
76class c6 { /// class with statics and constructor2
77    /// s1 comment
78    static s1: number; /// s1 comment2
79    /// constructor comment
80    constructor() { /// constructor comment2
81    }
82}
83let i6 = new c6();
84AssertType(i6, "c6");
85AssertType(new c6(), "c6");
86AssertType(c6, "typeof c6");
87
88let i6_c = c6;
89AssertType(i6_c, "typeof c6");
90AssertType(c6, "typeof c6");
91
92// class with statics and constructor
93class c7 {
94    // s1 comment
95    static s1: number;
96    // constructor comment
97    constructor() {
98    }
99}
100let i7 = new c7();
101AssertType(i7, "c7");
102AssertType(new c7(), "c7");
103AssertType(c7, "typeof c7");
104
105let i7_c = c7;
106AssertType(i7_c, "typeof c7");
107AssertType(c7, "typeof c7");
108
109/** class with statics and constructor
110 */
111class c8 {
112    /** s1 comment */
113    static s1: number; /** s1 comment2 */
114    /** constructor comment
115    */
116    constructor() {
117        /** constructor comment2
118        */
119    }
120}
121let i8 = new c8();
122AssertType(i8, "c8");
123AssertType(new c8(), "c8");
124AssertType(c8, "typeof c8");
125
126let i8_c = c8;
127AssertType(i8_c, "typeof c8");
128AssertType(c8, "typeof c8");
129
130class c9 {
131    constructor() {
132        /// This is some detached comment
133
134        // should emit this leading comment of } too
135    }
136}
137
138
139