@@ -4,7 +4,7 @@ import { ValueTypeToParse } from "./utils";
44import { WhereBuilder } from "./../crud/where-builder" ;
55import { DatabaseHelper } from "./../database-helper" ;
66import { ProjectionBuilder } from "./../crud/projection-builder" ;
7- import { Expression , ExpressionUtils , LambdaColumnMetadata , LambdaExpression } from "lambda-expression" ;
7+ import { Expression , ExpressionUtils , LambdaColumnMetadata , LambdaExpression , ReturnExpression } from "lambda-expression" ;
88import { LambdaMetadata } from "./lambda-metadata" ;
99import { ExpressionOrColumnEnum } from "./enums/expression-or-column-enum" ;
1010import { FieldType } from "./enums/field-type" ;
@@ -22,7 +22,7 @@ export type ValueTypeToParse = ValueType | moment.Moment | Date | object;
2222
2323export type TypeOrString < T > = ( new ( ) => T ) | string ;
2424
25- export type ExpressionOrColumn < T > = Expression < T > | string ;
25+ export type ExpressionOrColumn < TReturn , T > = ReturnExpression < TReturn , T > | string ;
2626
2727export type TypeWhere < T > = Expression < T > | ValueTypeToParse | ColumnRef | ProjectionsHelper < T > ;
2828
@@ -123,8 +123,8 @@ export class Utils {
123123 return instance instanceof PlanRef ;
124124 }
125125
126- public static expressionOrColumn < T > (
127- value : ExpressionOrColumn < T >
126+ public static expressionOrColumn < TReturn , T > (
127+ value : ExpressionOrColumn < TReturn , T >
128128 ) : ExpressionOrColumnEnum {
129129 return this . isString ( value )
130130 ? ExpressionOrColumnEnum . Column
@@ -147,7 +147,7 @@ export class Utils {
147147 return this . isString ( param ) ? param as string : ( param as ( new ( ) => T ) ) . name ;
148148 }
149149
150- public static getColumn < T > ( expression : ExpressionOrColumn < T > ) : string {
150+ public static getColumn < TReturn , T > ( expression : ExpressionOrColumn < TReturn , T > ) : string {
151151 const type = this . expressionOrColumn ( expression ) ;
152152 switch ( type ) {
153153 case ( ExpressionOrColumnEnum . Expression ) :
@@ -197,7 +197,7 @@ export class Utils {
197197 return new ProjectionCompiled ( expression + "" ) ;
198198 }
199199
200- public static getValue < T > ( instance : any , expression : ExpressionOrColumn < T > ) : any {
200+ public static getValue < TReturn , T > ( instance : any , expression : ExpressionOrColumn < TReturn , T > ) : TReturn {
201201 return this . expressionOrColumn ( expression ) === ExpressionOrColumnEnum . Expression
202202 ? this . getExpressionUtils ( ) . getValueByExpression ( instance , expression as Expression < T > )
203203 : this . getExpressionUtils ( ) . getValue ( instance , expression as string ) ;
@@ -208,8 +208,8 @@ export class Utils {
208208 }
209209
210210 public static getType ( instance : ValueTypeToParse ) : FieldType ;
211- public static getType < T > ( instance : any , expression : ExpressionOrColumn < T > ) : FieldType ;
212- public static getType < T > ( instance : any , expression ?: ExpressionOrColumn < T > ) : FieldType {
211+ public static getType < TReturn extends ValueTypeToParse , T > ( instance : any , expression : ExpressionOrColumn < TReturn , T > ) : FieldType ;
212+ public static getType < TReturn extends ValueTypeToParse , T > ( instance : any , expression ?: ExpressionOrColumn < TReturn , T > ) : FieldType {
213213 if ( expression ) {
214214 return this . getTypeByValue ( this . getValue ( instance , expression ) ) ;
215215 }
0 commit comments