• 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
23const hello = ({ // NOT OK
24  firstName,
25  lastName,
26}: {
27  firstName: string;
28  lastName: string;
29}): string => `Hello ${firstName} ${lastName}`;
30console.log(hello({ firstName: 'Karl', lastName: 'Marks' }));
31
32const person = { firstName: 'Adam', lastName: 'Smith' };
33console.log(hello(person));
34
35interface I {
36  d: number
37}
38
39function f1({d = 1}: I) { // NOT OK
40}
41f1({d:2})
42
43function f2({d = 1}: {d: number}) { // NOT OK
44}
45f2({d:2})
46
47function f3({x, ...y}) { // NOT OK
48  console.log(x);
49  Object.keys(y).forEach(k => console.log(k, y[k]))
50}
51f3({x: 1, b: 2, c: 3})
52
53function f4([a, b]): void {
54  console.log(a, b);
55}
56f4(['Hello', 'Wolrd']);
57
58function f5([a, b]: number[]): void {
59  console.log(a, b);
60}
61f5([1, 2, 3]);
62
63function f6([a, [b, c]]): void {
64  console.log(a, b, c);
65}
66f6([1, [2, 3]]);
67
68function f7([a, b, ...c]) { // NOT OK
69  console.log(a, b, c);
70}
71f7([1, 2, 3, 4])
72
73function f8([a, b, [c, ...d]]) { // NOT OK
74  console.log(a, b, c, d);
75}
76f8([1, 2, [3, 4, 5]])
77
78function f9([a, {b, c}]): void { // NOT OK
79  console.log(a, b, c);
80}
81f9([1, {b: 2, c: 3}]);
82
83function f10([a, [b, {c: d, e: f}]]): void { // NOT OK
84  console.log(a, b, d, f);
85}
86f10([1, [2, {c : 3, e: 4}]]);
87
88function f11([a, b]: Set<number>): void { // NOT OK
89  console.log(a, b);
90}
91f11(new Set([1, 2, 3, 4]));
92