Skip to content

Commit

Permalink
fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
markov00 committed May 27, 2024
1 parent 972cb7b commit 6ff5507
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,12 @@ export function FormulaEditor({

let errors: ErrorWrapper[] = [];

const { root, error } = tryToParse(text, visibleOperationsMap);
if (error) {
errors = [error];
} else if (root) {
const parseResponse = tryToParse(text, visibleOperationsMap);
if ('error' in parseResponse) {
errors = [parseResponse.error];
} else {
const validationErrors = runASTValidation(
root,
parseResponse.root,
layer,
indexPattern,
visibleOperationsMap,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ function parseAndExtract(
dateRange: DateRange | undefined,
label?: string
) {
const { root, error } = tryToParse(text, operations);
if (error || root == null) {
const parseResponse = tryToParse(text, operations);
if ('error' in parseResponse) {
return { extracted: [], isValid: false };
}
// before extracting the data run the validation task and throw if invalid
const errors = runASTValidation(
root,
parseResponse.root,
layer,
indexPattern,
operations,
Expand All @@ -67,7 +67,7 @@ function parseAndExtract(
const extracted = extractColumns(
columnId,
operations,
root,
parseResponse.root,
layer,
indexPattern,
i18n.translate('xpack.lens.indexPattern.formulaPartLabel', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ export function tryToParse(
formula: string,
operations: Record<string, unknown>
): { root: TinymathAST } | { error: ErrorWrapper } {
let root;
let root: TinymathAST;
try {
root = parse(formula);
} catch (e) {
Expand Down

0 comments on commit 6ff5507

Please sign in to comment.