@sheetxl/primitives 0.7.28-beta.4 → 0.8.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/esm/index.mjs +101 -55
- package/node/esm/index.mjs +115 -67
- package/package.json +3 -4
- package/types/src/ErrorPolicy.d.ts +48 -57
- package/types/src/Flatten.d.ts +6 -3
- package/types/src/FormulaContext.d.ts +47 -7
- package/types/src/IFormulaContext.d.ts +223 -11
- package/types/src/IFunction.d.ts +368 -39
- package/types/src/IFunctionArguments.d.ts +214 -0
- package/types/src/IRange.d.ts +199 -40
- package/types/src/IRangeStats.d.ts +34 -3
- package/types/src/IRuntime.d.ts +24 -1
- package/types/src/Lazy.d.ts +76 -0
- package/types/src/NoFilter.d.ts +34 -0
- package/types/src/NoLift.d.ts +31 -0
- package/types/src/Repeating.d.ts +24 -4
- package/types/src/ReportType.d.ts +42 -0
- package/types/src/Scalar.d.ts +1 -1
- package/types/src/ValueKind.d.ts +43 -0
- package/types/src/Volatile.d.ts +12 -0
- package/types/src/WildCard.d.ts +13 -9
- package/types/src/index.d.ts +7 -0
- package/browser/cjs/index.cjs +0 -1
package/types/src/IFunction.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Scalar } from './Scalar';
|
|
2
2
|
import { ScalarType } from './ScalarType';
|
|
3
|
+
import { ValueKind } from './ValueKind';
|
|
3
4
|
/**
|
|
4
5
|
* A self-describing, type-safe, executable function.
|
|
5
6
|
*
|
|
@@ -35,6 +36,22 @@ export interface IFunction {
|
|
|
35
36
|
* Indicates whether the function is a built-in function.
|
|
36
37
|
*/
|
|
37
38
|
isBuiltIn(): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Indicates whether the function is a `LAMBDA` rather than a built-in or registered function.
|
|
41
|
+
*
|
|
42
|
+
* @remarks
|
|
43
|
+
* Two kinds of function answer `true`:
|
|
44
|
+
*
|
|
45
|
+
* - **A defined name whose body is `LAMBDA(…)`.** It is reachable by name like any other
|
|
46
|
+
* function, so signature help and function lookups can describe it: its parameters are the
|
|
47
|
+
* lambda's, and its summary is the name's comment, or the name's formula when it has no
|
|
48
|
+
* comment. A formula calls it through the NAME, never through {@link execute}, which answers
|
|
49
|
+
* `#CALC!`.
|
|
50
|
+
* - **A `LAMBDA` passed as a value** and received by
|
|
51
|
+
* {@link IFunctionArguments.getFunctionsAt}. It has no name ({@link getName} is `''`), its
|
|
52
|
+
* parameters are the lambda's, and {@link execute} applies it.
|
|
53
|
+
*/
|
|
54
|
+
isLambda(): boolean;
|
|
38
55
|
/**
|
|
39
56
|
* Returns the execution environment this function belongs to.
|
|
40
57
|
*
|
|
@@ -125,17 +142,47 @@ export declare namespace IFunction {
|
|
|
125
142
|
*/
|
|
126
143
|
getName(): string;
|
|
127
144
|
/**
|
|
128
|
-
*
|
|
145
|
+
* True when a BARE error at this parameter — an error instead of a value or a range, `NA()`,
|
|
146
|
+
* `#NAME?`, a union where one rectangle is needed — is delivered to the body RAW rather than
|
|
147
|
+
* propagated: the `AcceptError<T>` marker. A rule, not a type — the engine's auto-reject is
|
|
148
|
+
* off at this slot, and the body narrows with `FormulaError.isError` if it cares.
|
|
129
149
|
*
|
|
130
150
|
* @remarks
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
151
|
+
* The default, and the common case, is that the error propagates with its identity and the
|
|
152
|
+
* body never runs. The marker never looks INSIDE a container: an error member of a range
|
|
153
|
+
* reaches the body either way and is the body's to judge (`IRange.firstError`).
|
|
154
|
+
*
|
|
155
|
+
* @see {@link ParameterTypeJSON.acceptError}
|
|
156
|
+
*/
|
|
157
|
+
isAcceptError(): boolean;
|
|
158
|
+
/**
|
|
159
|
+
* True when a multi-cell REFERENCE at this scalar parameter is `#VALUE!` rather than a
|
|
160
|
+
* broadcast — the `NoLift<T>` marker.
|
|
161
|
+
*
|
|
162
|
+
* @see {@link ParameterTypeJSON.noLift}
|
|
163
|
+
*/
|
|
164
|
+
isNoLift(): boolean;
|
|
165
|
+
/**
|
|
166
|
+
* True when the members reaching this repeating scalar parameter are coerced rather than
|
|
167
|
+
* filtered — the `NoFilter<T>` marker.
|
|
168
|
+
*
|
|
169
|
+
* @see {@link ParameterTypeJSON.noFilter}
|
|
170
|
+
*/
|
|
171
|
+
isNoFilter(): boolean;
|
|
172
|
+
/**
|
|
173
|
+
* True when the argument at this parameter may reach the body UNEVALUATED, as an `ILazy`
|
|
174
|
+
* handle — the `Lazy<T>` marker.
|
|
135
175
|
*
|
|
136
|
-
* @see {@link ParameterTypeJSON.
|
|
176
|
+
* @see {@link ParameterTypeJSON.lazy}
|
|
137
177
|
*/
|
|
138
|
-
|
|
178
|
+
isLazy(): boolean;
|
|
179
|
+
/**
|
|
180
|
+
* True when the parameter takes EITHER a value or a range, decided per argument by its kind —
|
|
181
|
+
* an `IRange | Scalar` union.
|
|
182
|
+
*
|
|
183
|
+
* @see {@link ParameterTypeJSON.valueOrRange}
|
|
184
|
+
*/
|
|
185
|
+
isValueOrRange(): boolean;
|
|
139
186
|
/**
|
|
140
187
|
* Indicates whether the parameter is required.
|
|
141
188
|
*/
|
|
@@ -181,11 +228,60 @@ export declare namespace IFunction {
|
|
|
181
228
|
*/
|
|
182
229
|
isRest(): boolean;
|
|
183
230
|
/**
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
231
|
+
* The enum the parameter is limited to, or `null` when it takes any value of its type.
|
|
232
|
+
*
|
|
233
|
+
* @remarks
|
|
234
|
+
* Declared by typing the parameter as a TypeScript `enum`, as an alias paired with a same-name
|
|
235
|
+
* `as const` object, or as a union of number or string literals (`0 | 1`).
|
|
236
|
+
*
|
|
237
|
+
* @see {@link IEnum}
|
|
187
238
|
*/
|
|
188
|
-
|
|
239
|
+
getEnum(): IFunction.IEnum | null;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* One member of an {@link IEnum}.
|
|
243
|
+
*/
|
|
244
|
+
interface IEnumMember {
|
|
245
|
+
/**
|
|
246
|
+
* The declared member name (`End`). For a union of bare literals, which names nothing, this is
|
|
247
|
+
* the value as text.
|
|
248
|
+
*/
|
|
249
|
+
getName(): string;
|
|
250
|
+
/**
|
|
251
|
+
* The value a formula passes. Typed, and never localized.
|
|
252
|
+
*/
|
|
253
|
+
getValue(): number | string;
|
|
254
|
+
/**
|
|
255
|
+
* Whether the member is declared but not offered, from the member's `@deprecated` tag.
|
|
256
|
+
*
|
|
257
|
+
* @remarks
|
|
258
|
+
* A deprecated member stays in the set, so a formula that passes it is not refused and the
|
|
259
|
+
* function decides what it answers. It is left out of the argument dropdown and the values
|
|
260
|
+
* a warning lists. A string is the tag's label (`Excel desktop only`).
|
|
261
|
+
*/
|
|
262
|
+
isDeprecated(): boolean | string;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* A closed set of values a parameter accepts.
|
|
266
|
+
*
|
|
267
|
+
* @remarks
|
|
268
|
+
* All members are numbers or all are strings; the two never mix. The set is free-form: it does
|
|
269
|
+
* not have to be contiguous or start at zero (`-1 | 0 | 1`).
|
|
270
|
+
*/
|
|
271
|
+
interface IEnum {
|
|
272
|
+
/**
|
|
273
|
+
* The declared type name (`PaymentType`), unique within the module that declares it. For a
|
|
274
|
+
* union of bare literals it is the values joined by `|`.
|
|
275
|
+
*/
|
|
276
|
+
getId(): string;
|
|
277
|
+
/**
|
|
278
|
+
* Whether the members are numbers or strings.
|
|
279
|
+
*/
|
|
280
|
+
getScalarType(): typeof ScalarType.Number | typeof ScalarType.String;
|
|
281
|
+
/**
|
|
282
|
+
* The members, in declaration order.
|
|
283
|
+
*/
|
|
284
|
+
getMembers(): readonly IFunction.IEnumMember[];
|
|
189
285
|
}
|
|
190
286
|
/**
|
|
191
287
|
* Describes the runtime return behavior of a function, including modifiers like
|
|
@@ -196,6 +292,14 @@ export declare namespace IFunction {
|
|
|
196
292
|
* If none are specified, The value will be returned with no special behavior.
|
|
197
293
|
*/
|
|
198
294
|
interface IReturnType extends IValueType {
|
|
295
|
+
/**
|
|
296
|
+
* The declared {@link ValueKind} of the result — the declared override where one exists, else
|
|
297
|
+
* the kind the type spellings imply — or `null` when the result's kind follows the value
|
|
298
|
+
* itself (`'*'`, an untyped return).
|
|
299
|
+
*
|
|
300
|
+
* @see {@link ReturnTypeJSON.kind}
|
|
301
|
+
*/
|
|
302
|
+
getKind(): ValueKind | null;
|
|
199
303
|
/**
|
|
200
304
|
* Indicates the return value is a Promise or Promise-like (i.e., async).
|
|
201
305
|
* The system will mark the result as pending and re-trigger evaluation once resolved.
|
|
@@ -209,6 +313,17 @@ export declare namespace IFunction {
|
|
|
209
313
|
* @defaultValue `false`
|
|
210
314
|
*/
|
|
211
315
|
isStreaming(): boolean;
|
|
316
|
+
/**
|
|
317
|
+
* True when the result can change with nothing dirty, so a cell naming this function
|
|
318
|
+
* recalculates on every pass — the `Volatile<T>` marker.
|
|
319
|
+
*
|
|
320
|
+
* @remarks
|
|
321
|
+
* STATIC, and read from the formula text at compile time: it is true of the call whether or
|
|
322
|
+
* not the call runs, which is what a lazy argument (and Excel) requires.
|
|
323
|
+
*
|
|
324
|
+
* @see {@link ReturnTypeJSON.volatile}
|
|
325
|
+
*/
|
|
326
|
+
isVolatile(): boolean;
|
|
212
327
|
}
|
|
213
328
|
/**
|
|
214
329
|
* The type-system metadata the engine reads to coerce arguments, apply broadcasting,
|
|
@@ -237,12 +352,32 @@ export declare namespace IFunction {
|
|
|
237
352
|
* If not specified, the function is assumed to be volatile (its output might change even if its inputs haven't).
|
|
238
353
|
*/
|
|
239
354
|
getParameters(): readonly IParameterType[];
|
|
355
|
+
/**
|
|
356
|
+
* The largest number of arguments a call to this function may carry.
|
|
357
|
+
*
|
|
358
|
+
* @remarks
|
|
359
|
+
* Only meaningful for a VARIADIC function; a fixed parameter list is already its own maximum.
|
|
360
|
+
* The number is the whole CALL's argument count, prefix and optional suffix included, and it
|
|
361
|
+
* is refused where Excel refuses it — at entry, before evaluation.
|
|
362
|
+
*
|
|
363
|
+
* @see {@link Repeating}
|
|
364
|
+
*/
|
|
365
|
+
getMaxArguments(): number;
|
|
240
366
|
/**
|
|
241
367
|
* Metadata describing the type and dimensionality of the return value.
|
|
242
368
|
*
|
|
243
369
|
* @defaultValue `{ type: 'void' }`
|
|
244
370
|
*/
|
|
245
371
|
getReturnType(): IReturnType;
|
|
372
|
+
/**
|
|
373
|
+
* Whether the function is left out of function lists, from its `@hidden` or `@deprecated` tag.
|
|
374
|
+
*
|
|
375
|
+
* @remarks
|
|
376
|
+
* A hidden function is still callable from a formula and still found by name. Listing calls
|
|
377
|
+
* leave it out unless asked to include it. {@link IDescriptor.isDeprecated} carries the tag's
|
|
378
|
+
* label, if it has one.
|
|
379
|
+
*/
|
|
380
|
+
isHidden(): boolean;
|
|
246
381
|
}
|
|
247
382
|
/**
|
|
248
383
|
* Locale-specific, user-facing metadata: display name, summary, category, and
|
|
@@ -252,7 +387,11 @@ export declare namespace IFunction {
|
|
|
252
387
|
*/
|
|
253
388
|
interface IDescriptor {
|
|
254
389
|
/**
|
|
255
|
-
*
|
|
390
|
+
* The canonical name of the function, matching {@link IDeclaration.getName}.
|
|
391
|
+
*
|
|
392
|
+
* @remarks
|
|
393
|
+
* A descriptor may override the name; when it does not, this is the name of the function
|
|
394
|
+
* in code. Use {@link getNameLocal} for display.
|
|
256
395
|
*/
|
|
257
396
|
getName(): string;
|
|
258
397
|
/**
|
|
@@ -271,14 +410,11 @@ export declare namespace IFunction {
|
|
|
271
410
|
*/
|
|
272
411
|
getCategory(): string;
|
|
273
412
|
/**
|
|
274
|
-
*
|
|
275
|
-
*
|
|
276
|
-
*
|
|
277
|
-
* @defaultValue 'null'
|
|
413
|
+
* The label of the function's `@hidden` or `@deprecated` tag (`Unimplemented`), `true` for a tag
|
|
414
|
+
* with no label, or `false`.
|
|
278
415
|
*
|
|
279
416
|
* @remarks
|
|
280
|
-
*
|
|
281
|
-
* * This is useful for functions that are in beta or deprecated.
|
|
417
|
+
* Whether the function is listed is {@link IDeclaration.isHidden}; this is the text to show for it.
|
|
282
418
|
*/
|
|
283
419
|
isDeprecated(): boolean | string;
|
|
284
420
|
/**
|
|
@@ -297,6 +433,31 @@ export declare namespace IFunction {
|
|
|
297
433
|
example?: string;
|
|
298
434
|
defaultValue?: Scalar;
|
|
299
435
|
}>>;
|
|
436
|
+
/**
|
|
437
|
+
* Describe each enum the function's parameters are limited to.
|
|
438
|
+
*
|
|
439
|
+
* @remarks
|
|
440
|
+
* The keys are enum ids (see {@link IEnum.getId}), and within one the member names (see
|
|
441
|
+
* {@link IEnumMember.getName}). Every enum a parameter declares has an entry and every member
|
|
442
|
+
* has one within it, so a caller can read a label without checking: `nameLocal` falls back to
|
|
443
|
+
* the declared name. Values are never localized — they are on the declaration.
|
|
444
|
+
*/
|
|
445
|
+
getEnums(): Readonly<Record<string, IFunction.IEnumDescription>>;
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* The copy for one enum: what it is, and what each member means.
|
|
449
|
+
*/
|
|
450
|
+
interface IEnumDescription {
|
|
451
|
+
/** The enum's name in the user's language, or its declared name. */
|
|
452
|
+
readonly nameLocal: string;
|
|
453
|
+
/** What the enum controls. */
|
|
454
|
+
readonly summary?: string;
|
|
455
|
+
/** By member name. */
|
|
456
|
+
readonly members: Readonly<Record<string, {
|
|
457
|
+
/** The member's name in the user's language, or its declared name. */
|
|
458
|
+
readonly nameLocal: string;
|
|
459
|
+
readonly description?: string;
|
|
460
|
+
}>>;
|
|
300
461
|
}
|
|
301
462
|
/**
|
|
302
463
|
* Describes the type characteristics of a function parameter or return value.
|
|
@@ -394,7 +555,8 @@ export declare namespace IFunction {
|
|
|
394
555
|
* @remarks
|
|
395
556
|
* Descriptive rather than applied: an absent argument is never pushed, so the initializer
|
|
396
557
|
* supplies the value itself. It is recorded so help text, tooltips and completions can say
|
|
397
|
-
* "defaults to 3" without reading the source.
|
|
558
|
+
* "defaults to 3" without reading the source. The exception is a {@link lazy} slot, which has
|
|
559
|
+
* no initializer to run — `Lazy<T, V>` declares the default here and the engine applies it.
|
|
398
560
|
*
|
|
399
561
|
* Present for a literal initializer only. One computed from another argument
|
|
400
562
|
* (`numberS2: number = numberS`) has no value to record and leaves this undefined.
|
|
@@ -454,28 +616,126 @@ export declare namespace IFunction {
|
|
|
454
616
|
*/
|
|
455
617
|
repeating?: ParameterTypeJSON[];
|
|
456
618
|
/**
|
|
457
|
-
*
|
|
458
|
-
*
|
|
619
|
+
* A BARE error at this parameter — an error instead of a value or a range — is delivered to
|
|
620
|
+
* the body RAW rather than propagated: the engine's auto-reject is off at this slot, and the
|
|
621
|
+
* body narrows if it cares. Generated from the `AcceptError<T>` marker. A failed COERCION to
|
|
622
|
+
* the declared type is delivered the same way, as the `#VALUE!` it would have raised, so a
|
|
623
|
+
* body that rethrows what it receives answers exactly as the engine would have — and one that
|
|
624
|
+
* reads its arguments in its own order can (`IFS(TRUE,1,"x",2)` is 1: the pair is never
|
|
625
|
+
* reached).
|
|
626
|
+
*
|
|
627
|
+
* @remarks
|
|
628
|
+
* OMITTED is the default (ErrorPolicy.ts): the error propagates with its identity (a scalar
|
|
629
|
+
* argument), becomes an error member of the output (a lifted member), or short-circuits on the
|
|
630
|
+
* first error in argument order (a flattened list) — the body never runs. A
|
|
631
|
+
* `FormulaError.Known`-typed parameter receives without the marker, because the type declares
|
|
632
|
+
* it. On a TYPED range (`IRange<number>`) the marker also lets error members ride through the
|
|
633
|
+
* typed read raw — COUNT's profile. Errors INSIDE a range are otherwise never the marker's
|
|
634
|
+
* business: a valid range is handed over whole.
|
|
635
|
+
*/
|
|
636
|
+
acceptError?: boolean;
|
|
637
|
+
/**
|
|
638
|
+
* The argument's subtree may be handed over UNEVALUATED, as an `ILazy` handle the body either
|
|
639
|
+
* returns unread or forces with `getValue()`. Generated from the `Lazy<T>` marker.
|
|
459
640
|
*
|
|
460
|
-
*
|
|
461
|
-
*
|
|
462
|
-
*
|
|
463
|
-
*
|
|
641
|
+
* @remarks
|
|
642
|
+
* A declaration, not a request: the engine defers where it can and DECLINES where it cannot
|
|
643
|
+
* (an absent argument, an async subtree, a lift that needs every arm), handing over a handle
|
|
644
|
+
* that is already full. Either way the body sees a handle and nothing else, which is why the
|
|
645
|
+
* marker is a contract rather than something inferred from what the body happens to read.
|
|
646
|
+
*
|
|
647
|
+
* Only a RESULT position carries it — `IF`'s branches, `CHOOSE`'s arms, `IFERROR`'s fallback.
|
|
648
|
+
* A condition, an index or a case value is eager, so `AND(FALSE,A1)` still reads `A1` and is
|
|
649
|
+
* still a circular reference.
|
|
650
|
+
*
|
|
651
|
+
* {@link defaultValue} is APPLIED at a lazy slot rather than merely recorded: the parameter
|
|
652
|
+
* cannot carry an initializer of its own (`= false` does not typecheck against a handle), so
|
|
653
|
+
* `Lazy<T, V>` declares it and the engine supplies it for an absent argument.
|
|
464
654
|
*
|
|
465
|
-
*
|
|
466
|
-
* error propagates with its identity (scalar argument), becomes an error member of the output
|
|
467
|
-
* (lifted member), or short-circuits on the first error in row-major order (range/array
|
|
468
|
-
* member). Only a `FormulaError.Known`-typed parameter receives without a marker, because the
|
|
469
|
-
* type declares it. There is no `'reject'` value: it would say what omitting this says.
|
|
655
|
+
* @see {@link Lazy}
|
|
470
656
|
*/
|
|
471
|
-
|
|
657
|
+
lazy?: boolean;
|
|
472
658
|
/**
|
|
473
|
-
*
|
|
474
|
-
*
|
|
659
|
+
* A multi-cell REFERENCE at this scalar parameter is `#VALUE!` rather than a broadcast.
|
|
660
|
+
* Generated from the `NoLift<T>` marker.
|
|
475
661
|
*
|
|
476
|
-
* @
|
|
662
|
+
* @remarks
|
|
663
|
+
* Per parameter, because Excel is: `NETWORKDAYS.INTL` refuses a reference at its date slots
|
|
664
|
+
* and lifts one at `weekend`. An ARRAY at the slot still lifts, a one-cell reference is an
|
|
665
|
+
* ordinary argument, and a repeating slot absorbs a container as members, so the marker only
|
|
666
|
+
* ever applies to a non-repeating scalar parameter.
|
|
667
|
+
*/
|
|
668
|
+
noLift?: boolean;
|
|
669
|
+
/**
|
|
670
|
+
* The members reaching this repeating scalar parameter are COERCED rather than filtered, and
|
|
671
|
+
* one that cannot be coerced is `#VALUE!` for the whole call. Generated from the `NoFilter<T>`
|
|
672
|
+
* marker.
|
|
673
|
+
*
|
|
674
|
+
* @remarks
|
|
675
|
+
* Numeric text parses, a blank inside a multi-cell range reads 0, and a boolean or
|
|
676
|
+
* non-numeric text member refuses — Excel's Analysis-ToolPak reading of a repeating slot,
|
|
677
|
+
* where the native family skips all three (`GCD({6,"8",12})` is 2 where `SUM` would answer
|
|
678
|
+
* over 6 and 12 alone). Only a repeating slot has members, so the marker applies nowhere
|
|
679
|
+
* else; a non-repeating scalar's counterpart is {@link noLift}.
|
|
477
680
|
*/
|
|
478
|
-
|
|
681
|
+
noFilter?: boolean;
|
|
682
|
+
/**
|
|
683
|
+
* The declared type is ADVISORY: the engine delivers it when it can and hands the body the
|
|
684
|
+
* raw argument when it cannot, instead of answering `#VALUE!` at the slot. Generated from the
|
|
685
|
+
* `ReportType<T>` marker.
|
|
686
|
+
*
|
|
687
|
+
* @remarks
|
|
688
|
+
* The type still reaches the function help, the wizard and the linter — it is what the slot
|
|
689
|
+
* means to a caller. It stops being a gate, so the BODY owns every answer the engine would
|
|
690
|
+
* otherwise have given: a union reaches it as `IRange[]`, a value or an error reaches it as
|
|
691
|
+
* itself. See {@link IFunctionArguments.getKindAt} and
|
|
692
|
+
* {@link IFunctionArguments.getAreaCountAt} for the discriminators.
|
|
693
|
+
*/
|
|
694
|
+
reportType?: boolean;
|
|
695
|
+
/**
|
|
696
|
+
* The parameter takes EITHER a value or a range — declared as a two-member union of a bare
|
|
697
|
+
* range type and a scalar type (`IRange | Scalar`, `IReferenceRange | number`) — and the
|
|
698
|
+
* marshaller picks the arm by the ARGUMENT's kind: a value, a bare error or a one-cell
|
|
699
|
+
* reference is the scalar arm (dereferenced, coerced to {@link scalar}, its fault raised in
|
|
700
|
+
* argument order like any scalar slot's); a multi-cell reference, an array or a reference
|
|
701
|
+
* union is the range arm, handed over whole. The slot never lifts.
|
|
702
|
+
*
|
|
703
|
+
* @remarks
|
|
704
|
+
* Excel reads a one-cell argument at some array slots as THE ARGUMENT rather than as a
|
|
705
|
+
* one-cell container: `SORT(<#N/A cell>,1,1,<#DIV/0! cell>)` is `#N/A` where
|
|
706
|
+
* `TAKE(<#N/A cell>,<#DIV/0! cell>)` is `#DIV/0!`. The engine's default
|
|
707
|
+
* for a range slot is TAKE's; this flag is SORT's. {@link scalar} and {@link range} each carry
|
|
708
|
+
* their arm, a pair that without this flag reads as a TYPED range (`IRange<number>`).
|
|
709
|
+
*/
|
|
710
|
+
valueOrRange?: boolean;
|
|
711
|
+
/**
|
|
712
|
+
* The closed set of values the parameter accepts. Generated from a parameter typed as a
|
|
713
|
+
* TypeScript `enum`, as an alias paired with a same-name `as const` object, or as a union of
|
|
714
|
+
* number or string literals. {@link scalar} carries the members' type.
|
|
715
|
+
*
|
|
716
|
+
* @remarks
|
|
717
|
+
* Parameters that share a declared enum share one `EnumJSON`, by {@link EnumJSON.id}.
|
|
718
|
+
*/
|
|
719
|
+
enum?: EnumJSON;
|
|
720
|
+
}
|
|
721
|
+
/**
|
|
722
|
+
* The JSON form of an {@link IEnum}.
|
|
723
|
+
*/
|
|
724
|
+
interface EnumJSON {
|
|
725
|
+
/**
|
|
726
|
+
* The declared type name, unique within the declaring module. A union of bare literals has no
|
|
727
|
+
* name, so its id is the values joined by `|`.
|
|
728
|
+
*/
|
|
729
|
+
id: string;
|
|
730
|
+
/**
|
|
731
|
+
* Whether the members are numbers or strings. The two never mix.
|
|
732
|
+
*/
|
|
733
|
+
type: typeof ScalarType.Number | typeof ScalarType.String;
|
|
734
|
+
/**
|
|
735
|
+
* The members, in declaration order. A union of bare literals names nothing, so each name is
|
|
736
|
+
* the value as text.
|
|
737
|
+
*/
|
|
738
|
+
members: [name: string, value: number | string, deprecated?: string | true][];
|
|
479
739
|
}
|
|
480
740
|
/**
|
|
481
741
|
* Describes the runtime return behavior of a function, including modifiers like
|
|
@@ -485,6 +745,24 @@ export declare namespace IFunction {
|
|
|
485
745
|
* If none are specified, The value will be returned with no special behavior.
|
|
486
746
|
*/
|
|
487
747
|
interface ReturnTypeJSON extends ValueTypeJSON {
|
|
748
|
+
/**
|
|
749
|
+
* The declared {@link ValueKind} of the result, where the inherited type spellings cannot say
|
|
750
|
+
* it. Generated from the `@returnKind` marker.
|
|
751
|
+
*
|
|
752
|
+
* @remarks
|
|
753
|
+
* A return type is a pair — is the call a REFERENCE, and what is its value kind. Both halves
|
|
754
|
+
* usually derive from the type spellings: {@link ValueTypeJSON.range} `'p'` (an
|
|
755
|
+
* `IReferenceRange` return, which a function whose value paths are casts may also use —
|
|
756
|
+
* `XLOOKUP`, `TAKE`) is `Reference`; `'r'`/`'m'` is `Array`; a concrete
|
|
757
|
+
* {@link ValueTypeJSON.scalar} is that scalar kind; `'*'` or an untyped return follows the
|
|
758
|
+
* value itself. This field overrides the derivation for the one spelling that loses it — a
|
|
759
|
+
* union like `number[] | number[][]` (`ROW`) collapses to `'*'`, yet the function's one-cell
|
|
760
|
+
* answer is a SCALAR (`TYPE(ROW(A1))` is 1 where `TYPE(TRANSPOSE({5}))` is 64).
|
|
761
|
+
*
|
|
762
|
+
* The engine applies the kind at the call exit: a one-cell range result whose declared kind
|
|
763
|
+
* is a scalar is its member value downstream.
|
|
764
|
+
*/
|
|
765
|
+
kind?: ValueKind;
|
|
488
766
|
/**
|
|
489
767
|
* Indicates the return value is a Promise or Promise-like (i.e., async).
|
|
490
768
|
* The system will mark the result as pending and re-trigger evaluation once resolved.
|
|
@@ -498,6 +776,20 @@ export declare namespace IFunction {
|
|
|
498
776
|
* @defaultValue `false`
|
|
499
777
|
*/
|
|
500
778
|
stream?: boolean;
|
|
779
|
+
/**
|
|
780
|
+
* The result can change with nothing dirty — a cell naming this function recalculates on
|
|
781
|
+
* every pass. Generated from the `Volatile<T>` marker.
|
|
782
|
+
*
|
|
783
|
+
* @remarks
|
|
784
|
+
* Collected at COMPILE time from the formula text (`CompiledFormula.hasVolatile`), because
|
|
785
|
+
* that is where Excel decides it: `=IF(TRUE,1,RAND())` recalculates on every idle pass though
|
|
786
|
+
* no branch selects the arm, and with lazy arguments the call never happens for the engine to
|
|
787
|
+
* observe. Sits beside {@link async} and {@link stream} because all three are about WHEN a
|
|
788
|
+
* result arrives rather than what it is.
|
|
789
|
+
*
|
|
790
|
+
* @see {@link Volatile}
|
|
791
|
+
*/
|
|
792
|
+
volatile?: boolean;
|
|
501
793
|
}
|
|
502
794
|
/**
|
|
503
795
|
* Contains metadata about a function declaration, including its name, return type, parameters, and additional documentation.
|
|
@@ -509,6 +801,20 @@ export declare namespace IFunction {
|
|
|
509
801
|
returnType?: ReturnTypeJSON;
|
|
510
802
|
/** @inheritdoc IFunction.IDeclaration.getParameters */
|
|
511
803
|
parameters?: ParameterTypeJSON[];
|
|
804
|
+
/**
|
|
805
|
+
* The largest number of arguments a call may carry, from `Repeating<T, Max>` on the variadic
|
|
806
|
+
* parameter. Omitted at the default of 255.
|
|
807
|
+
*
|
|
808
|
+
* @remarks
|
|
809
|
+
* Excel keeps one such number per NAME and compares it against the whole call's argument
|
|
810
|
+
* count in its front end, so a call past it is refused AT ENTRY rather than answered — which
|
|
811
|
+
* is why the cap lives on the declaration and not in a body. It is not derivable from the
|
|
812
|
+
* shape: `STDEV` takes 255 arguments and `STDEV.S`, the same function under its dotted name,
|
|
813
|
+
* takes 254.
|
|
814
|
+
*
|
|
815
|
+
* @defaultValue 255
|
|
816
|
+
*/
|
|
817
|
+
maxArguments?: number;
|
|
512
818
|
/**
|
|
513
819
|
* Describes the execution context required by the function.
|
|
514
820
|
*
|
|
@@ -531,6 +837,14 @@ export declare namespace IFunction {
|
|
|
531
837
|
* * If the context is not `IFunction.Calculation` then the function must return `void` or a cleanup function.
|
|
532
838
|
*/
|
|
533
839
|
context?: string;
|
|
840
|
+
/**
|
|
841
|
+
* Leave the function out of function lists.
|
|
842
|
+
*
|
|
843
|
+
* @defaultValue `false`
|
|
844
|
+
*
|
|
845
|
+
* @see {@link IDeclaration.isHidden}
|
|
846
|
+
*/
|
|
847
|
+
hidden?: boolean;
|
|
534
848
|
/**
|
|
535
849
|
* Additional metadata about the function's behavior or requirements.
|
|
536
850
|
*/
|
|
@@ -565,13 +879,12 @@ export declare namespace IFunction {
|
|
|
565
879
|
*/
|
|
566
880
|
category?: string;
|
|
567
881
|
/**
|
|
568
|
-
*
|
|
882
|
+
* The label of a `@hidden` or `@deprecated` tag, or `true` for a tag with no label.
|
|
569
883
|
*
|
|
570
|
-
* @defaultValue
|
|
884
|
+
* @defaultValue `false`
|
|
571
885
|
*
|
|
572
886
|
* @remarks
|
|
573
|
-
*
|
|
574
|
-
* * This is useful for functions that are in beta or deprecated.
|
|
887
|
+
* Display text only. Whether the function is listed is {@link DeclarationJSON.hidden}.
|
|
575
888
|
*/
|
|
576
889
|
deprecated?: string | boolean;
|
|
577
890
|
/**
|
|
@@ -586,6 +899,22 @@ export declare namespace IFunction {
|
|
|
586
899
|
example?: string;
|
|
587
900
|
defaultValue?: Scalar;
|
|
588
901
|
}>;
|
|
902
|
+
/**
|
|
903
|
+
* Describe each enum the function's parameters are limited to, by enum id.
|
|
904
|
+
*/
|
|
905
|
+
enums?: Record<string, EnumDescriptorJSON>;
|
|
906
|
+
}
|
|
907
|
+
/**
|
|
908
|
+
* The JSON form of an {@link IEnumDescription}. Every field is optional: an enum with no doc
|
|
909
|
+
* comments has nothing to say, and a language pack may translate any part of one.
|
|
910
|
+
*/
|
|
911
|
+
interface EnumDescriptorJSON {
|
|
912
|
+
nameLocal?: string;
|
|
913
|
+
summary?: string;
|
|
914
|
+
members?: Record<string, {
|
|
915
|
+
nameLocal?: string;
|
|
916
|
+
description?: string;
|
|
917
|
+
}>;
|
|
589
918
|
}
|
|
590
919
|
/**
|
|
591
920
|
* Contains extended metadata about a function that is not be directly inferable from the code itself.
|