Skip to content

Commit

Permalink
refactor: add FormulaFunctionValueType export
Browse files Browse the repository at this point in the history
  • Loading branch information
hexf00 committed Jan 2, 2025
1 parent 250bb37 commit cbc13e0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import { BaseValueObject, ErrorValueObject } from './base-value-object';

export type PrimitiveValueType = string | boolean | number | null;

export type FormulaFunctionValueType = PrimitiveValueType | PrimitiveValueType[][];

export class NullValueObject extends BaseValueObject {
private static _instance: NullValueObject;

Expand Down
7 changes: 4 additions & 3 deletions packages/engine-formula/src/functions/base-function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import type { IFunctionNames } from '../basics/function';
import type { BaseReferenceObject, FunctionVariantType, NodeValueType } from '../engine/reference-object/base-reference-object';
import type { ArrayBinarySearchType } from '../engine/utils/compare';
import type { ArrayValueObject } from '../engine/value-object/array-value-object';
import type { FormulaFunctionValueType } from '../engine/value-object/primitive-object';
import type { FormulaDataModel } from '../models/formula-data.model';
import type { IDefinedNameMapItem } from '../services/defined-names.service';
import { ErrorType } from '../basics/error-type';
Expand All @@ -33,7 +34,7 @@ import { ArrayOrderSearchType } from '../engine/utils/compare';
import { serializeRangeToRefString } from '../engine/utils/reference';
import { convertTonNumber } from '../engine/utils/value-object';
import { type BaseValueObject, ErrorValueObject } from '../engine/value-object/base-value-object';
import { NullValueObject, NumberValueObject, type PrimitiveValueType } from '../engine/value-object/primitive-object';
import { NullValueObject, NumberValueObject } from '../engine/value-object/primitive-object';

export class BaseFunction {
private _unitId: Nullable<string>;
Expand Down Expand Up @@ -191,8 +192,8 @@ export class BaseFunction {
}

calculateCustom(
...arg: Array<PrimitiveValueType | PrimitiveValueType[][]>
): PrimitiveValueType | PrimitiveValueType[][] | Promise<PrimitiveValueType | PrimitiveValueType[][]> {
...arg: Array<FormulaFunctionValueType>
): FormulaFunctionValueType | Promise<FormulaFunctionValueType> {
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/engine-formula/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export { handleRefStringInfo } from './engine/utils/reference';
export { generateStringWithSequence, type ISequenceNode, sequenceNodeType } from './engine/utils/sequence';
export { ArrayValueObject, ValueObjectFactory } from './engine/value-object/array-value-object';
export { BaseValueObject, ErrorValueObject } from './engine/value-object/base-value-object';
export type { PrimitiveValueType } from './engine/value-object/primitive-object';
export type { FormulaFunctionValueType, PrimitiveValueType } from './engine/value-object/primitive-object';
export { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from './engine/value-object/primitive-object';
export { functionArray } from './functions/array/function-map';
export { FUNCTION_NAMES_ARRAY } from './functions/array/function-names';
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 { IFunctionInfo, PrimitiveValueType } from '@univerjs/engine-formula';
import type { FormulaFunctionValueType, IFunctionInfo } from '@univerjs/engine-formula';
import { createIdentifier, Disposable, DisposableCollection, Inject, LocaleService, Optional, toDisposable } from '@univerjs/core';
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[][]>
) => PrimitiveValueType | PrimitiveValueType[][] | Promise<PrimitiveValueType | PrimitiveValueType[][]>;
...arg: Array<FormulaFunctionValueType>
) => FormulaFunctionValueType | Promise<FormulaFunctionValueType>;

// [[Function, FunctionName, Description]]
export type IRegisterFunctionList = [[IRegisterFunction, string, string?]];
Expand Down

0 comments on commit cbc13e0

Please sign in to comment.