• 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
16type UpdateFunc = (u: Record<string, Object>) => Record<string, Object>;
17type ReducerFunc = (key: string) => Record<string, Object>;
18
19export const updateIfChanged = (t: Record<string, Object>) => {
20  const reducerFunc: ReducerFunc = (key) => {
21    const value = u[key];
22    const reduceResult = reduce(
23      value as Record<string, Object>,
24      (v: Record<string, Object>) => {
25        const baseU = u;
26        const updatedU: Record<string, Object> = {
27          ...baseU,
28          [key]: v
29        };
30        return update(updatedU);
31      }
32    );
33    return reduceResult;
34  };
35};
36
37/* @@? 21:19 Error TypeError: Unresolved reference u */
38/* @@? 21:19 Error TypeError: Indexed access is not supported for such expression type. */
39/* @@? 24:7 Error TypeError: Type '(v: Record<String,Object>) => Boolean' is not compatible with type '(previousValue: Boolean, currentValue: Boolean, index: Double, array: FixedArray<boolean>) => Boolean' at index 2 */
40/* @@? 27:11 Error SyntaxError: Property or signature expected. */
41/* @@? 28:11 Error SyntaxError: Unexpected token. */
42/* @@? 28:12 Error SyntaxError: Unexpected token. */
43/* @@? 28:15 Error SyntaxError: Unexpected token. */
44/* @@? 28:16 Error SyntaxError: Unexpected token ':'. */
45/* @@? 28:18 Error SyntaxError: Unexpected token 'v'. */
46/* @@? 29:10 Error SyntaxError: Unexpected token, expected ',' or ')'. */
47/* @@? 30:16 Error TypeError: Unresolved reference update */
48/* @@? 32:5 Error SyntaxError: Unexpected token ')'. */
49/* @@? 33:12 Error TypeError: Unresolved reference reduceResult */
50/* @@? 35:1 Error SyntaxError: Unexpected token '}'. */
51