diff --git a/CHANGELOG.md b/CHANGELOG.md index 42327ed5..d8316499 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/). ## [Unreleased] ### Added +- Added types for `SELECT.hints()` of `cds.ql` API + ### Changed - `CHANGELOG.md` and `LICENSE` files are no longer part of the npm package. diff --git a/apis/internal/query.d.ts b/apis/internal/query.d.ts index 37573672..1cf496ca 100644 --- a/apis/internal/query.d.ts +++ b/apis/internal/query.d.ts @@ -145,6 +145,11 @@ export interface Limit { & ((rows: number, offset?: number) => this) } +export interface Hints { + hints: ((...hints: string[]) => this) + & ((hints: string[]) => this) +} + export interface And { and: TaggedTemplateQueryPart & ((predicate: object) => this) diff --git a/apis/ql.d.ts b/apis/ql.d.ts index ab95470d..dd0f9cc3 100644 --- a/apis/ql.d.ts +++ b/apis/ql.d.ts @@ -15,6 +15,7 @@ import { Columns, EntityDescription, Having, + Hints, GroupBy, Limit, OrderBy, @@ -74,7 +75,7 @@ export declare class QL { } -export interface SELECT extends Where, And, Having, GroupBy, OrderBy, Limit { +export interface SELECT extends Where, And, Having, GroupBy, OrderBy, Limit, Hints { // overload specific to SELECT columns: Columns['columns'] & ((projection: Projection) => this) } diff --git a/test/typescript/apis/project/cds-ql.ts b/test/typescript/apis/project/cds-ql.ts index c30c4e0c..98a8b979 100644 --- a/test/typescript/apis/project/cds-ql.ts +++ b/test/typescript/apis/project/cds-ql.ts @@ -60,6 +60,10 @@ SELECT.from(Foos, f => f.ref(r => r.x)) // ref should be callable without optio SELECT.from(Foos).orderBy('x') // x auto completed SELECT.from(Foos).orderBy('y') // non-columns also still possible +SELECT.from(Foos).hints('x') +SELECT.from(Foos).hints('x', 'y') +SELECT.from(Foos).hints(['x', 'y']) + SELECT.from(Foos, f => { f.x, // @ts-expect-error - foobar is not a valid column