13af6ab5fSopenharmony_ci/* 23af6ab5fSopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd. 33af6ab5fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 43af6ab5fSopenharmony_ci * you may not use this file except in compliance with the License. 53af6ab5fSopenharmony_ci * You may obtain a copy of the License at 63af6ab5fSopenharmony_ci * 73af6ab5fSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 83af6ab5fSopenharmony_ci * 93af6ab5fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 103af6ab5fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 113af6ab5fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 123af6ab5fSopenharmony_ci * See the License for the specific language governing permissions and 133af6ab5fSopenharmony_ci * limitations under the License. 143af6ab5fSopenharmony_ci */ 153af6ab5fSopenharmony_ci 163af6ab5fSopenharmony_cifunction drawText({ text = '', position: [x, y] = [0, 0] }): void { // NOT OK 173af6ab5fSopenharmony_ci // Draw text 183af6ab5fSopenharmony_ci} 193af6ab5fSopenharmony_cidrawText({ text: 'Figure 1', position: [10, 20] }); 203af6ab5fSopenharmony_ci 213af6ab5fSopenharmony_ciconst hello = ({ // NOT OK 223af6ab5fSopenharmony_ci firstName, 233af6ab5fSopenharmony_ci lastName, 243af6ab5fSopenharmony_ci}: { 253af6ab5fSopenharmony_ci firstName: string; 263af6ab5fSopenharmony_ci lastName: string; 273af6ab5fSopenharmony_ci}): string => `Hello ${firstName} ${lastName}`; 283af6ab5fSopenharmony_ciconsole.log(hello({ firstName: 'Karl', lastName: 'Marks' })); 293af6ab5fSopenharmony_ci 303af6ab5fSopenharmony_ciconst person = { firstName: 'Adam', lastName: 'Smith' }; 313af6ab5fSopenharmony_ciconsole.log(hello(person)); 323af6ab5fSopenharmony_ci 333af6ab5fSopenharmony_ciinterface I { 343af6ab5fSopenharmony_ci d: number 353af6ab5fSopenharmony_ci} 363af6ab5fSopenharmony_ci 373af6ab5fSopenharmony_cifunction f1({d = 1}: I) { // NOT OK 383af6ab5fSopenharmony_ci} 393af6ab5fSopenharmony_cif1({d:2}) 403af6ab5fSopenharmony_ci 413af6ab5fSopenharmony_cifunction f2({d = 1}: {d: number}) { // NOT OK 423af6ab5fSopenharmony_ci} 433af6ab5fSopenharmony_cif2({d:2}) 443af6ab5fSopenharmony_ci 453af6ab5fSopenharmony_cifunction f3({x, ...y}) { // NOT OK 463af6ab5fSopenharmony_ci console.log(x); 473af6ab5fSopenharmony_ci Object.keys(y).forEach(k => console.log(k, y[k])) 483af6ab5fSopenharmony_ci} 493af6ab5fSopenharmony_cif3({x: 1, b: 2, c: 3}) 503af6ab5fSopenharmony_ci 513af6ab5fSopenharmony_cifunction f4([a, b]): void { 523af6ab5fSopenharmony_ci console.log(a, b); 533af6ab5fSopenharmony_ci} 543af6ab5fSopenharmony_cif4(['Hello', 'Wolrd']); 553af6ab5fSopenharmony_ci 563af6ab5fSopenharmony_cifunction f5([a, b]: number[]): void { 573af6ab5fSopenharmony_ci console.log(a, b); 583af6ab5fSopenharmony_ci} 593af6ab5fSopenharmony_cif5([1, 2, 3]); 603af6ab5fSopenharmony_ci 613af6ab5fSopenharmony_cifunction f6([a, [b, c]]): void { 623af6ab5fSopenharmony_ci console.log(a, b, c); 633af6ab5fSopenharmony_ci} 643af6ab5fSopenharmony_cif6([1, [2, 3]]); 653af6ab5fSopenharmony_ci 663af6ab5fSopenharmony_cifunction f7([a, b, ...c]) { // NOT OK 673af6ab5fSopenharmony_ci console.log(a, b, c); 683af6ab5fSopenharmony_ci} 693af6ab5fSopenharmony_cif7([1, 2, 3, 4]) 703af6ab5fSopenharmony_ci 713af6ab5fSopenharmony_cifunction f8([a, b, [c, ...d]]) { // NOT OK 723af6ab5fSopenharmony_ci console.log(a, b, c, d); 733af6ab5fSopenharmony_ci} 743af6ab5fSopenharmony_cif8([1, 2, [3, 4, 5]]) 753af6ab5fSopenharmony_ci 763af6ab5fSopenharmony_cifunction f9([a, {b, c}]): void { // NOT OK 773af6ab5fSopenharmony_ci console.log(a, b, c); 783af6ab5fSopenharmony_ci} 793af6ab5fSopenharmony_cif9([1, {b: 2, c: 3}]); 803af6ab5fSopenharmony_ci 813af6ab5fSopenharmony_cifunction f10([a, [b, {c: d, e: f}]]): void { // NOT OK 823af6ab5fSopenharmony_ci console.log(a, b, d, f); 833af6ab5fSopenharmony_ci} 843af6ab5fSopenharmony_cif10([1, [2, {c : 3, e: 4}]]); 853af6ab5fSopenharmony_ci 863af6ab5fSopenharmony_cifunction f11([a, b]: Set<number>): void { // NOT OK 873af6ab5fSopenharmony_ci console.log(a, b); 883af6ab5fSopenharmony_ci} 893af6ab5fSopenharmony_cif11(new Set([1, 2, 3, 4])); 90