Skip to content
Snippets Groups Projects
Unverified Commit dbae664c authored by Uladzimir Havenchyk's avatar Uladzimir Havenchyk Committed by GitHub
Browse files

[Parameters] Cleanup types usage (#38752)

* [Parameters] Cleanup wrong tests

* fixup! [Parameters] Cleanup wrong tests
parent 4d552f13
No related branches found
No related tags found
No related merge requests found
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}`);
}
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment