Skip to content

Commit

Permalink
fix(facade): fix ts ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
Dushusir committed Dec 18, 2024
1 parent fb42cc2 commit fde6140
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions packages/engine-formula/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,4 @@ export { ENGINE_FORMULA_CYCLE_REFERENCE_COUNT, ENGINE_FORMULA_PLUGIN_CONFIG_KEY,

export { generateRandomDependencyTreeId } from './engine/dependency/formula-dependency';
export { DependencyManagerBaseService } from './services/dependency-manager.service';
export { LambdaValueObjectObject } from './engine/value-object/lambda-value-object';
14 changes: 8 additions & 6 deletions packages/facade/src/apis/__tests__/facade.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

import type { ICellData, Injector, Nullable } from '@univerjs/core';
import type { LambdaValueObjectObject, PrimitiveValueType } from '@univerjs/engine-formula';
import type {
ColumnHeaderLayout,
RenderComponentType,
Expand All @@ -24,8 +25,8 @@ import type {
SpreadsheetRowHeader,
} from '@univerjs/engine-render';
import type { FUniver } from '../everything';
import { ICommandService, IUniverInstanceService } from '@univerjs/core';

import { ICommandService, IUniverInstanceService } from '@univerjs/core';
import { RegisterFunctionMutation, SetFormulaCalculationStartMutation } from '@univerjs/engine-formula';
import { IRenderManagerService } from '@univerjs/engine-render';
import { SetRangeValuesCommand, SetRangeValuesMutation, SetStyleCommand } from '@univerjs/sheets';
Expand Down Expand Up @@ -178,19 +179,20 @@ describe('Test FUniver', () => {

it('Function registerFunction', () => {
const funcionName = 'CUSTOMSUM';

const functionsDisposable = univerAPI.registerFunction({
calculate: [
[function (...variants) {
let sum = 0;

const last = variants[variants.length - 1];
// @ts-ignore
const last = variants[variants.length - 1] as LambdaValueObjectObject;

if (last.isLambda()) {
variants.pop();

const variantsList = variants.map((variant) => Array.isArray(variant) ? variant[0][0] : variant);
// @ts-ignore
sum += last.executeCustom(...variantsList).getValue();
const variantsList = variants.map((variant) => Array.isArray(variant) ? variant[0][0] : variant) as PrimitiveValueType[];

sum += +last.executeCustom(...variantsList).getValue();
}

for (const variant of variants) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
*/

import type { IDisposable, ILocales } from '@univerjs/core';
import type { BaseValueObject, IFunctionInfo, PrimitiveValueType } from '@univerjs/engine-formula';
import { createIdentifier, Disposable, DisposableCollection, Inject, LocaleService, Optional, toDisposable } from '@univerjs/core';
import type { IFunctionInfo, PrimitiveValueType } from '@univerjs/engine-formula';
import { CustomFunction, FunctionType, IFunctionService } from '@univerjs/engine-formula';

import { IDescriptionService } from './description.service';
import { IRemoteRegisterFunctionService } from './remote/remote-register-function.service';

export type IRegisterFunction = (
...arg: Array<PrimitiveValueType | PrimitiveValueType[][]>
...arg: Array<PrimitiveValueType | PrimitiveValueType[][] | BaseValueObject>
) => PrimitiveValueType | PrimitiveValueType[][];

// [[Function, FunctionName, Description]]
Expand Down

0 comments on commit fde6140

Please sign in to comment.