In FQL, it is possible to specify null
as the default value returned by Select
. In the example below, null
is returned if the matched document doesn’t have a user
field:
Select(
["data", "user"],
Get(Match(Index("unique_Identity_id"), CurrentIdentity())),
null
)
However the type annotations for the JS driver do not allow you to specify null
:
type ExprVal = Expr | string | number | boolean | { [key: string]: any }
type ExprArg = ExprVal | Array<ExprVal>
export function Select(path: ExprArg, from: ExprArg, _default?: ExprArg): Expr
With the example above, this is what would happen:
Select(
["data", "user"],
Get(Match(Index("unique_Identity_id"), CurrentIdentity())),
null
// ^^^^
// Argument of type 'null' is not assignable
// to parameter of type 'ExprArg | undefined'.
);
Is the type annotation correct or intentional?