Skip to content

Commit

Permalink
Merge pull request #284 from AnyhowStep/explicit-type-annotations-for…
Browse files Browse the repository at this point in the history
…-operators

Related to #283
  • Loading branch information
AnyhowStep authored Mar 7, 2020
2 parents e5a0d16 + 4d3b1c3 commit e7602d8
Show file tree
Hide file tree
Showing 167 changed files with 412 additions and 358 deletions.
26 changes: 13 additions & 13 deletions src/design-pattern-log/util/correlated-subquery/latest-value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@ export type LatestValue<
}>
);

export type LatestValueSelectValueDelegate<
export interface LatestValueSelectValueDelegate<
LogT extends ILog,
BuiltInExprT extends AnyBuiltInExpr
> =
SelectValueDelegate<
FromClauseUtil.From<
FromClauseUtil.RequireOuterQueryJoins<
FromClauseUtil.NewInstance,
[LogT["ownerTable"]]
>,
LogT["logTable"]
> extends SelectValueDelegate<
FromClauseUtil.From<
FromClauseUtil.NewInstanceWithOuterQueryJoins<
false,
[LogT["ownerTable"]]
>,
undefined,
BuiltInExprT
>
;
LogT["logTable"]
>,
undefined,
BuiltInExprT
> {

}

export function latestValue<
LogT extends ILog,
Expand Down
3 changes: 1 addition & 2 deletions src/design-pattern-log/util/correlated-subquery/latest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ export type Latest<LogT extends ILog> = (
QueryUtil.OrderBy<
QueryUtil.Where<
QueryUtil.From<
QueryUtil.RequireOuterQueryJoins<
QueryUtil.NewInstance,
QueryUtil.NewInstanceWithOuterQueryJoins<
[LogT["ownerTable"]]
>,
LogT["logTable"]
Expand Down
4 changes: 2 additions & 2 deletions src/expr-library/aggregate/count-all.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as tm from "type-mapping";
import {OperatorType} from "../../operator-type";
import {makeAggregateOperator0} from "../aggregate-factory";
import {makeAggregateOperator0, AggregateOperator0} from "../aggregate-factory";

/**
* Returns a count of the number of rows
Expand All @@ -18,7 +18,7 @@ import {makeAggregateOperator0} from "../aggregate-factory";
* @todo Rename to `count`? or `countRow`?
* @todo Or add a function `count()` with overloads for `countExpr` and `countAll`?
*/
export const countAll = makeAggregateOperator0<OperatorType.AGGREGATE_COUNT_ALL, bigint>(
export const countAll : AggregateOperator0<bigint> = makeAggregateOperator0<OperatorType.AGGREGATE_COUNT_ALL, bigint>(
OperatorType.AGGREGATE_COUNT_ALL,
/**
* Should not return a value less than zero
Expand Down
4 changes: 2 additions & 2 deletions src/expr-library/aggregate/count-expr.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as tm from "type-mapping";
import {OperatorType} from "../../operator-type";
import {makeAggregateOperator2, AggregateOperator1} from "../aggregate-factory";
import {makeAggregateOperator2, AggregateOperator2, AggregateOperator1} from "../aggregate-factory";
import {BuiltInExpr_NonAggregate} from "../../built-in-expr";
import {ExprUtil} from "../../expr";

const countExprImpl = makeAggregateOperator2<OperatorType.AGGREGATE_COUNT_EXPR, boolean, unknown, bigint>(
const countExprImpl : AggregateOperator2<boolean, unknown, bigint> = makeAggregateOperator2<OperatorType.AGGREGATE_COUNT_EXPR, boolean, unknown, bigint>(
OperatorType.AGGREGATE_COUNT_EXPR,
/**
* Should not return a value less than zero
Expand Down
4 changes: 2 additions & 2 deletions src/expr-library/cast/cast-as-n-char.ts.deprecated
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as tm from "type-mapping";
import {makeOperator1Idempotent} from "../factory";
import {makeOperator1Idempotent, Operator1} from "../factory";
import {OperatorType} from "../../operator-type";
import {BuiltInValueExpr} from "../../built-in-value-expr";
import {Decimal} from "../../decimal";

export const castAsNChar = makeOperator1Idempotent<OperatorType.CAST_AS_N_CHAR, BuiltInValueExpr|Decimal, string|null>(
export const castAsNChar : Operator1<BuiltInValueExpr|Decimal, string|null> = makeOperator1Idempotent<OperatorType.CAST_AS_N_CHAR, BuiltInValueExpr|Decimal, string|null>(
OperatorType.CAST_AS_N_CHAR,
tm.mysql.longText().orNull()
);
4 changes: 2 additions & 2 deletions src/expr-library/cast/unsafe-cast-as-bigint-signed.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as tm from "type-mapping";
import {makeOperator1Idempotent} from "../factory";
import {makeOperator1Idempotent, Operator1} from "../factory";
import {OperatorType} from "../../operator-type";

/**
Expand Down Expand Up @@ -27,7 +27,7 @@ import {OperatorType} from "../../operator-type";
* + https://github.com/AnyhowStep/tsql/issues/244
* + https://github.com/AnyhowStep/tsql/issues/245
*/
export const unsafeCastAsBigIntSigned = makeOperator1Idempotent<OperatorType.CAST_AS_BIGINT_SIGNED, unknown, bigint|null>(
export const unsafeCastAsBigIntSigned : Operator1<unknown, bigint|null> = makeOperator1Idempotent<OperatorType.CAST_AS_BIGINT_SIGNED, unknown, bigint|null>(
OperatorType.CAST_AS_BIGINT_SIGNED,
tm.mysql.bigIntSigned().orNull()
);
4 changes: 2 additions & 2 deletions src/expr-library/cast/unsafe-cast-as-binary.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as tm from "type-mapping/fluent";
import {makeOperator1Idempotent} from "../factory";
import {makeOperator1Idempotent, Operator1} from "../factory";
import {OperatorType} from "../../operator-type";

/**
Expand All @@ -26,7 +26,7 @@ import {OperatorType} from "../../operator-type";
*
* + https://github.com/AnyhowStep/tsql/issues/15
*/
export const unsafeCastAsBinary = makeOperator1Idempotent<OperatorType.CAST_AS_BINARY, unknown, Uint8Array|null>(
export const unsafeCastAsBinary : Operator1<unknown, Uint8Array|null> = makeOperator1Idempotent<OperatorType.CAST_AS_BINARY, unknown, Uint8Array|null>(
OperatorType.CAST_AS_BINARY,
tm.instanceOfUint8Array().orNull()
);
4 changes: 2 additions & 2 deletions src/expr-library/cast/unsafe-cast-as-double.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as tm from "type-mapping";
import {makeOperator1Idempotent} from "../factory";
import {makeOperator1Idempotent, Operator1} from "../factory";
import {OperatorType} from "../../operator-type";

/**
Expand Down Expand Up @@ -30,7 +30,7 @@ import {OperatorType} from "../../operator-type";
*
* + https://github.com/AnyhowStep/tsql/issues/15
*/
export const unsafeCastAsDouble = makeOperator1Idempotent<OperatorType.CAST_AS_DOUBLE, unknown, number|null>(
export const unsafeCastAsDouble : Operator1<unknown, number|null> = makeOperator1Idempotent<OperatorType.CAST_AS_DOUBLE, unknown, number|null>(
OperatorType.CAST_AS_DOUBLE,
tm.orNull(tm.toUnsafeNumber())
);
4 changes: 2 additions & 2 deletions src/expr-library/cast/unsafe-cast-as-json.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as tm from "type-mapping";
import {makeOperator1Idempotent} from "../factory";
import {makeOperator1Idempotent, Operator1} from "../factory";
import {OperatorType} from "../../operator-type";

/**
Expand Down Expand Up @@ -32,7 +32,7 @@ import {OperatorType} from "../../operator-type";
*
* + https://github.com/AnyhowStep/tsql/issues/15
*/
export const unsafeCastAsJson = makeOperator1Idempotent<OperatorType.CAST_AS_JSON, unknown, string|null>(
export const unsafeCastAsJson : Operator1<unknown, string|null> = makeOperator1Idempotent<OperatorType.CAST_AS_JSON, unknown, string|null>(
OperatorType.CAST_AS_JSON,
tm.orNull(tm.string())
);
4 changes: 2 additions & 2 deletions src/expr-library/cast/unsafe-cast-as-var-char.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as tm from "type-mapping";
import {makeOperator1Idempotent} from "../factory";
import {makeOperator1Idempotent, Operator1} from "../factory";
import {OperatorType} from "../../operator-type";

/**
Expand Down Expand Up @@ -27,7 +27,7 @@ import {OperatorType} from "../../operator-type";
*
* + https://github.com/AnyhowStep/tsql/issues/15
*/
export const unsafeCastAsVarChar = makeOperator1Idempotent<OperatorType.CAST_AS_VARCHAR, unknown, string|null>(
export const unsafeCastAsVarChar : Operator1<unknown, string|null> = makeOperator1Idempotent<OperatorType.CAST_AS_VARCHAR, unknown, string|null>(
OperatorType.CAST_AS_VARCHAR,
tm.orNull(tm.string())
);
4 changes: 2 additions & 2 deletions src/expr-library/comparison/between.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {makeComparison3} from "../factory";
import {makeComparison3, Comparison3} from "../factory";
import {OperatorType} from "../../operator-type";

/**
Expand All @@ -9,6 +9,6 @@ import {OperatorType} from "../../operator-type";
* For null-safe checks, @see {@link nullSafeBetween}
*
*/
export const between = makeComparison3(
export const between : Comparison3 = makeComparison3(
OperatorType.BETWEEN_AND
);
4 changes: 2 additions & 2 deletions src/expr-library/comparison/gt-eq.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {makeComparison2} from "../factory";
import {makeComparison2, Comparison2} from "../factory";
import {OperatorType} from "../../operator-type";

/**
Expand All @@ -7,6 +7,6 @@ import {OperatorType} from "../../operator-type";
* This version of the `>=` operator prevents `NULL`.
*
*/
export const gtEq = makeComparison2(
export const gtEq : Comparison2 = makeComparison2(
OperatorType.GREATER_THAN_OR_EQUAL
);
4 changes: 2 additions & 2 deletions src/expr-library/comparison/gt.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {makeComparison2} from "../factory";
import {makeComparison2, Comparison2} from "../factory";
import {OperatorType} from "../../operator-type";

/**
Expand All @@ -7,6 +7,6 @@ import {OperatorType} from "../../operator-type";
* This version of the `>` operator prevents `NULL`.
*
*/
export const gt = makeComparison2(
export const gt : Comparison2 = makeComparison2(
OperatorType.GREATER_THAN
);
4 changes: 2 additions & 2 deletions src/expr-library/comparison/lt-eq.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {makeComparison2} from "../factory";
import {makeComparison2, Comparison2} from "../factory";
import {OperatorType} from "../../operator-type";

/**
Expand All @@ -7,6 +7,6 @@ import {OperatorType} from "../../operator-type";
* This version of the `<=` operator prevents `NULL`.
*
*/
export const ltEq = makeComparison2(
export const ltEq : Comparison2 = makeComparison2(
OperatorType.LESS_THAN_OR_EQUAL
);
4 changes: 2 additions & 2 deletions src/expr-library/comparison/lt.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {makeComparison2} from "../factory";
import {makeComparison2, Comparison2} from "../factory";
import {OperatorType} from "../../operator-type";

/**
Expand All @@ -7,6 +7,6 @@ import {OperatorType} from "../../operator-type";
* This version of the `<` operator prevents `NULL`.
*
*/
export const lt = makeComparison2(
export const lt : Comparison2 = makeComparison2(
OperatorType.LESS_THAN
);
4 changes: 2 additions & 2 deletions src/expr-library/comparison/not-between.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {makeComparison3} from "../factory";
import {makeComparison3, Comparison3} from "../factory";
import {OperatorType} from "../../operator-type";

/**
Expand All @@ -9,6 +9,6 @@ import {OperatorType} from "../../operator-type";
* For null-safe checks, @see {@link nullSafeNotBetween}
*
*/
export const notBetween = makeComparison3(
export const notBetween : Comparison3 = makeComparison3(
OperatorType.NOT_BETWEEN_AND
);
4 changes: 2 additions & 2 deletions src/expr-library/date-time/current-date.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as tm from "type-mapping";
import {makeOperator0} from "../factory";
import {makeOperator0, Operator0} from "../factory";
import {OperatorType} from "../../operator-type";
import {TypeHint} from "../../type-hint";

Expand All @@ -20,7 +20,7 @@ import {TypeHint} from "../../type-hint";
*
* Sets hour, minute, second, millisecond to zero.
*/
export const currentDate = makeOperator0<OperatorType.CURRENT_DATE, Date>(
export const currentDate : Operator0<Date> = makeOperator0<OperatorType.CURRENT_DATE, Date>(
OperatorType.CURRENT_DATE,
tm.mysql.dateTime(0),
TypeHint.DATE_TIME
Expand Down
10 changes: 5 additions & 5 deletions src/expr-library/date-time/current-time.ts.todo
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as tm from "type-mapping";
import {makeOperator0} from "../factory";
import {makeOperator0, Operator0} from "../factory";
import {OperatorType} from "../../operator-type";
import {TypeHint} from "../../type-hint";

Expand All @@ -20,7 +20,7 @@ import {TypeHint} from "../../type-hint";
*
* Sets year, month, day, to the unix epoch
*/
export const currentTime0 = makeOperator0<OperatorType.CURRENT_TIME_0, Date>(
export const currentTime0 : Operator0<Date> = makeOperator0<OperatorType.CURRENT_TIME_0, Date>(
OperatorType.CURRENT_TIME_0,
tm.mysql.dateTime(0),
TypeHint.DATE_TIME
Expand All @@ -29,7 +29,7 @@ export const currentTime0 = makeOperator0<OperatorType.CURRENT_TIME_0, Date>(
/**
* Sets year, month, day, to the unix epoch
*/
export const currentTime1 = makeOperator0<OperatorType.CURRENT_TIME_1, Date>(
export const currentTime1 : Operator0<Date> = makeOperator0<OperatorType.CURRENT_TIME_1, Date>(
OperatorType.CURRENT_TIME_1,
tm.mysql.dateTime(1),
TypeHint.DATE_TIME
Expand All @@ -38,7 +38,7 @@ export const currentTime1 = makeOperator0<OperatorType.CURRENT_TIME_1, Date>(
/**
* Sets year, month, day, to the unix epoch
*/
export const currentTime2 = makeOperator0<OperatorType.CURRENT_TIME_2, Date>(
export const currentTime2 : Operator0<Date> = makeOperator0<OperatorType.CURRENT_TIME_2, Date>(
OperatorType.CURRENT_TIME_2,
tm.mysql.dateTime(2),
TypeHint.DATE_TIME
Expand All @@ -47,7 +47,7 @@ export const currentTime2 = makeOperator0<OperatorType.CURRENT_TIME_2, Date>(
/**
* Sets year, month, day, to the unix epoch
*/
export const currentTime3 = makeOperator0<OperatorType.CURRENT_TIME_3, Date>(
export const currentTime3 : Operator0<Date> = makeOperator0<OperatorType.CURRENT_TIME_3, Date>(
OperatorType.CURRENT_TIME_3,
tm.mysql.dateTime(3),
TypeHint.DATE_TIME
Expand Down
10 changes: 5 additions & 5 deletions src/expr-library/date-time/current-timestamp.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as tm from "type-mapping";
import {makeOperator0} from "../factory";
import {makeOperator0, Operator0} from "../factory";
import {OperatorType} from "../../operator-type";
import {TypeHint} from "../../type-hint";

Expand All @@ -20,7 +20,7 @@ import {TypeHint} from "../../type-hint";
* > the `CURRENT_TIMESTAMP` function returns a `TIMESTAMP` **with** time zone.
* + SQLite : `strftime('%Y-%m-%d %H:%M:%S', 'now')` gives precision `0`
*/
export const currentTimestamp0 = makeOperator0<OperatorType.CURRENT_TIMESTAMP_0, Date>(
export const currentTimestamp0 : Operator0<Date> = makeOperator0<OperatorType.CURRENT_TIMESTAMP_0, Date>(
OperatorType.CURRENT_TIMESTAMP_0,
tm.mysql.dateTime(0),
TypeHint.DATE_TIME
Expand All @@ -43,7 +43,7 @@ export const currentTimestamp0 = makeOperator0<OperatorType.CURRENT_TIMESTAMP_0,
* > the `CURRENT_TIMESTAMP` function returns a `TIMESTAMP` **with** time zone.
* + SQLite : `substr(strftime('%Y-%m-%d %H:%M:%f', 'now'), 1, 21)` gives precision `1`
*/
export const currentTimestamp1 = makeOperator0<OperatorType.CURRENT_TIMESTAMP_1, Date>(
export const currentTimestamp1 : Operator0<Date> = makeOperator0<OperatorType.CURRENT_TIMESTAMP_1, Date>(
OperatorType.CURRENT_TIMESTAMP_1,
tm.mysql.dateTime(1),
TypeHint.DATE_TIME
Expand All @@ -66,7 +66,7 @@ export const currentTimestamp1 = makeOperator0<OperatorType.CURRENT_TIMESTAMP_1,
* > the `CURRENT_TIMESTAMP` function returns a `TIMESTAMP` **with** time zone.
* + SQLite : `substr(strftime('%Y-%m-%d %H:%M:%f', 'now'), 1, 22)` gives precision `2`
*/
export const currentTimestamp2 = makeOperator0<OperatorType.CURRENT_TIMESTAMP_2, Date>(
export const currentTimestamp2 : Operator0<Date> = makeOperator0<OperatorType.CURRENT_TIMESTAMP_2, Date>(
OperatorType.CURRENT_TIMESTAMP_2,
tm.mysql.dateTime(2),
TypeHint.DATE_TIME
Expand All @@ -89,7 +89,7 @@ export const currentTimestamp2 = makeOperator0<OperatorType.CURRENT_TIMESTAMP_2,
* > the `CURRENT_TIMESTAMP` function returns a `TIMESTAMP` **with** time zone.
* + SQLite : `strftime('%Y-%m-%d %H:%M:%f', 'now')` gives precision `3`
*/
export const currentTimestamp3 = makeOperator0<OperatorType.CURRENT_TIMESTAMP_3, Date>(
export const currentTimestamp3 : Operator0<Date> = makeOperator0<OperatorType.CURRENT_TIMESTAMP_3, Date>(
OperatorType.CURRENT_TIMESTAMP_3,
tm.mysql.dateTime(3),
TypeHint.DATE_TIME
Expand Down
Loading

0 comments on commit e7602d8

Please sign in to comment.