diff --git a/frontend/src/metabase-lib/parameters/utils/targets.ts b/frontend/src/metabase-lib/parameters/utils/targets.ts index 87749f9fc5c6dcb723376930fecbc2231fee82d1..58719fa08df7394679e68f3f7cbecd50a534da88 100644 --- a/frontend/src/metabase-lib/parameters/utils/targets.ts +++ b/frontend/src/metabase-lib/parameters/utils/targets.ts @@ -1,7 +1,6 @@ import type { - ExpressionReference, + ConcreteFieldReference, FieldReference, - LocalFieldReference, NativeParameterDimensionTarget, ParameterTarget, ParameterTextTarget, @@ -25,14 +24,8 @@ export function isParameterVariableTarget( function isConcreteFieldReference( reference: FieldReference, -): reference is LocalFieldReference { - return reference[0] === "field"; -} - -function isExpressionReference( - reference: FieldReference, -): reference is ExpressionReference { - return reference[0] === "expression"; +): reference is ConcreteFieldReference { + return reference[0] === "field" || reference[0] === "expression"; } export function getTemplateTagFromTarget(target: ParameterTarget) { @@ -74,7 +67,7 @@ export function buildColumnTarget( ): StructuredParameterDimensionTarget { const fieldRef = Lib.legacyRef(query, stageIndex, column); - if (!isConcreteFieldReference(fieldRef) && !isExpressionReference(fieldRef)) { + if (!isConcreteFieldReference(fieldRef)) { throw new Error(`Cannot build column target field reference: ${fieldRef}`); } diff --git a/frontend/src/metabase-lib/parameters/utils/targets.unit.spec.ts b/frontend/src/metabase-lib/parameters/utils/targets.unit.spec.ts index 4123e5773f60ee3cd231f8389e833f9973d5baea..be632e30f5ee6a0553ede775b29a2ccc83bac1e5 100644 --- a/frontend/src/metabase-lib/parameters/utils/targets.unit.spec.ts +++ b/frontend/src/metabase-lib/parameters/utils/targets.unit.spec.ts @@ -27,8 +27,6 @@ describe("parameters/utils/targets", () => { expect(isDimensionTarget(["variable", ["template-tag", "foo"]])).toBe( false, ); - // @ts-expect-error - this function is still used in untyped code -- making sure non-arrays don't blow up - expect(isDimensionTarget()).toBe(false); }); it('should return true for a target that contains a "dimension" string in the first entry', () => { @@ -67,10 +65,6 @@ describe("parameters/utils/targets", () => { }); it("should return null for targets that are not template tags", () => { - // @ts-expect-error - this function is still used in untyped code -- making sure non-arrays don't blow up - expect(getTemplateTagFromTarget(["dimension"])).toBe(null); - // @ts-expect-error - this function is still used in untyped code -- making sure non-arrays don't blow up - expect(getTemplateTagFromTarget()).toBe(null); expect( getTemplateTagFromTarget(["dimension", ["field", 123, null]]), ).toBe(null);