Skip to content

Commit 662cfe0

Browse files
authored
fix: cube-client-core resolveMember return type (#1051). Thanks to @Aaronkala
Add correct return type to Meta.resolveMember. The previous type of `Object` was incorrect.
1 parent 1e9bd99 commit 662cfe0

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

packages/cubejs-client-core/index.d.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,14 @@ declare module '@cubejs-client/core' {
673673
type TCubeDimension = TCubeMember & {
674674
suggestFilterValues: boolean;
675675
};
676+
677+
type TCubeSegment = Pick<TCubeMember, "name" | 'shortTitle' | "title">
678+
679+
type TCubeMemberByType<T> =
680+
T extends "measures" ? TCubeMeasure :
681+
T extends "dimensions" ? TCubeDimension :
682+
T extends "segments" ? TCubeSegment :
683+
never
676684

677685
type TDryRunResponse = {
678686
queryType: QueryType;
@@ -709,7 +717,7 @@ declare module '@cubejs-client/core' {
709717
* @param memberName - Fully qualified member name in a form `Cube.memberName`
710718
* @return An object containing meta information about member
711719
*/
712-
resolveMember(memberName: string, memberType: MemberType): Object;
720+
resolveMember<T extends MemberType>(memberName: string, memberType: T): { title: string, error: string } | TCubeMemberByType<T>;
713721
defaultTimeDimensionNameFor(memberName: string): string;
714722
filterOperatorsForMember(memberName: string, memberType: MemberType): any;
715723
}

0 commit comments

Comments
 (0)