Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] CQN predicates expect wrong types #32

Open
1 task done
siarhei-murkou opened this issue Feb 6, 2024 · 0 comments
Open
1 task done

[BUG] CQN predicates expect wrong types #32

siarhei-murkou opened this issue Feb 6, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@siarhei-murkou
Copy link

siarhei-murkou commented Feb 6, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Example:

import cqn from "@cap-js/cds-types";

const condition_1: cqn.predicate = [{ ref: ["prop_1"] }, "is", null];
const condition_2: cqn.predicate = [{ ref: ["prop_2"] }, "in", { val: ["val_1", "val_2"] }];

It leads to:

TS2322: Type { ref: string[]; } is not assignable to type
    Partial<string & ref & val & xpr & function_call & SELECT>
        Types of property valueOf are incompatible.
            Type () => Object is not assignable to type (() => string) & (() => Object)
                Type () => Object is not assignable to type () => string
                    Type Object is not assignable to type string

Expected Behavior

No TypeScript issues.

References

No references.

Versions

@cap-js/cds-typer: 0.15.0
@cap-js/sqlite: 1.2.1
@sap/cds: 7.5.3
@sap/cds-compiler: 4.0.2
@sap/cds-dk: 7.5.1
@sap/cds-dk (global): 7.3.1
@sap/cds-fiori: 1.1.0
@sap/cds-foss: 4.0.2
@sap/cds-mtxs: 1.14.2
@sap/eslint-plugin-cds: 2.6.4
Node.js: v18.18.2

Anything else? Logs?

As I got, the issue is due to this line:

export type predicate = UnionsToIntersections<_xpr>

Which is incorrect, because this intersection allows only string-like values. I suppose the value should be _xpr as it was defined in past.

@siarhei-murkou siarhei-murkou added the bug Something isn't working label Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant