• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 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
16// issue: 24982: Enable 'autofix' mode for this test to ensure it finishes without crashing
17
18function drawText({ text = '', position: [x, y] = [0, 0] }): void { // NOT OK
19  // Draw text
20}
21drawText({ text: 'Figure 1', position: [10, 20] });
22
23interface GeneratedTypeLiteralInterface_1 {
24    firstName: string;
25    lastName: string;
26}
27const hello = ({ // NOT OK
28  firstName,
29  lastName,
30}: GeneratedTypeLiteralInterface_1): string => `Hello ${firstName} ${lastName}`;
31console.log(hello({ firstName: 'Karl', lastName: 'Marks' }));
32
33interface GeneratedObjectLiteralInterface_1 {
34    firstName: string;
35    lastName: string;
36}
37const person: GeneratedObjectLiteralInterface_1 = { firstName: 'Adam', lastName: 'Smith' };
38console.log(hello(person));
39
40interface I {
41  d: number
42}
43
44function f1({d = 1}: I) { // NOT OK
45}
46f1({d:2})
47
48interface GeneratedTypeLiteralInterface_2 {
49    d: number;
50}
51function f2({d = 1}: GeneratedTypeLiteralInterface_2) { // NOT OK
52}
53f2({d:2})
54
55function f3({x, ...y}) { // NOT OK
56  console.log(x);
57  Object.keys(y).forEach(k => console.log(k, y[k]))
58}
59f3({x: 1, b: 2, c: 3})
60
61function f4([a, b]): void {
62  console.log(a, b);
63}
64f4(['Hello', 'Wolrd']);
65
66function f5([a, b]: number[]): void {
67  console.log(a, b);
68}
69f5([1, 2, 3]);
70
71function f6([a, [b, c]]): void {
72  console.log(a, b, c);
73}
74f6([1, [2, 3]]);
75
76function f7([a, b, ...c]) { // NOT OK
77  console.log(a, b, c);
78}
79f7([1, 2, 3, 4])
80
81function f8([a, b, [c, ...d]]) { // NOT OK
82  console.log(a, b, c, d);
83}
84f8([1, 2, [3, 4, 5]])
85
86function f9([a, {b, c}]): void { // NOT OK
87  console.log(a, b, c);
88}
89f9([1, {b: 2, c: 3}]);
90
91function f10([a, [b, {c: d, e: f}]]): void { // NOT OK
92  console.log(a, b, d, f);
93}
94f10([1, [2, {c : 3, e: 4}]]);
95
96function f11([a, b]: Set<number>): void { // NOT OK
97  console.log(a, b);
98}
99f11(new Set([1, 2, 3, 4]));
100