1/* 2 * Copyright (c) 2023-2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16class A { 17 public readonly x: number; 18protected y: number; 19private z: number; 20constructor( 21 x: number, 22 y: number, 23 z: number 24 ) { 25 this.x = x; 26 this.y = y; 27 this.z = z; 28} 29 30 foo(): void { 31 console.log(this.x + this.y + this.z); 32 } 33} 34 35const a = new A(1.0, 2.0, 3.0); 36console.log(a.x); 37 38class B { 39 public f: number = 10.0; 40 41 public w: string; 42private readonly r: number[]; 43constructor(q: number, w = 'default', e: boolean, r: number[] = [1.0, 2.0, 3.0]) { 44 this.w = w; 45 this.r = r; 46 console.log(q, this.w, e, this.r, this.f); 47} 48} 49 50const b = new B(1.0, '2', true, []); 51console.log(b.w); 52 53class C { 54 constructor(public a: any) {} // not fixable 55} 56 57interface GeneratedTypeLiteralInterface_1 { 58 x: string; 59} 60class D { 61 public a: number; 62private b: GeneratedTypeLiteralInterface_1; 63constructor(a: number, b: GeneratedTypeLiteralInterface_1) { 64 this.a = a; 65 this.b = b; 66} // not fixable 67} 68 69class E { 70 b: number = 0.0; 71 c: number = 0.0; 72 73 readonly a: number; 74constructor(a: number) { 75 this.a = a; 76} 77} 78 79class F extends E { 80 readonly aa: number; 81b: number; 82public c: number; 83constructor( 84 aa: number, 85 b: number, 86 c: number 87 ){ 88 super(aa); 89 this.aa = aa; 90 this.b = b; 91 this.c = c; 92} 93} 94 95class F2 extends E { 96 readonly aa: number; 97constructor(aa: number) { 98 let f2: number = 1.0; 99 console.log('before super() call'); 100 super(aa); 101 this.aa = aa; 102} 103} 104 105class F3 extends E { 106 readonly aa: number; 107constructor(aa: number) { 108 super(aa); 109 this.aa = aa; 110 let f3: number = 1.0; 111 console.log('after super() call'); 112} 113} 114 115class F4 extends E { 116 readonly aa: number; 117constructor(aa: number) { 118 let f4: number = 1.0; 119 console.log('before super() call'); 120 super(aa); 121 this.aa = aa; 122 console.log('after super() call'); 123 let f5: number = 1.0; 124} 125} 126 127class G { 128 constructor(a?: number) {} 129} 130 131class G1 { 132 public a?: number; 133public b: number; 134constructor(a?: number, b: number) { 135 this.a = a; 136 this.b = b; 137} 138} 139 140class G2 { 141 public a?: number; 142public b?: number; 143constructor(a?: number, b?: number) { 144 this.a = a; 145 this.b = b; 146} 147}