SQLDataSource icon indicating copy to clipboard operation
SQLDataSource copied to clipboard

Property 'cache' does not exist on type QueryBuilder

Open fondberg opened this issue 2 years ago • 3 comments

Does anyone know what can cause this?

src/datasources/order-api.ts(17,8): error TS2551: Property 'cache' does not exist on type 'QueryBuilder<{}, DeferredKeySelection<{}, string, false, {}, false, {}, undefined>>'. Did you mean 'catch'?

Relevant packages: "knex": "^2.0.0" "datasource-sql": "^2.0.1",

fondberg avatar May 20 '22 11:05 fondberg

I recently bumped the knex version to 2.0 but I am wondering if maybe the api changed?

cvburgess avatar Jun 09 '22 19:06 cvburgess

Is this fixed or is there a workaround to this issue?

askurat avatar Aug 04 '22 17:08 askurat

I think this is just a typing issue - typescript isn't seeing the knex type extension declared in index.d.ts, and is instead seeing the vanilla knex QueryBuilder type which doesn't include that function. The workaround that worked for me is just to add // @ts-ignore before the cache line:

.select('*')
.from("thing")
.limit(10)
// @ts-ignore
.cache(MINUTE);

alitheg avatar Sep 22 '22 10:09 alitheg

Is there any other fix for this than ignoring the ts issue? Also got this now when I upgraded.

arwidt avatar Oct 25 '22 10:10 arwidt

Also looking for a better fix for this. Adding ts-ignore has other side effects.

rafagsiqueira avatar Oct 28 '22 15:10 rafagsiqueira

Is there any fix for this yet?

DaviRolim avatar Jan 18 '23 10:01 DaviRolim

This should be resolved in 2.1.0 - thanks @daniel-keller

cvburgess avatar Apr 24 '23 16:04 cvburgess