Closed Meldiron closed 3 years ago
It is pretty urgent for me, so I tried to find a solution and I came up with this:
(terrible solution, I know, keep reading please)
In onWithJoinedColumnOperatorColumn
I found that column1Arguments
is parsed using getColumnName()
but it is not implemented for column2Arguments
.
I implemented getColumnName()
for column2Arguments
but I kept getting errors (it was using wrong table). It uses a function getColumnNameWithoutAlias()
which uses getColumnInformation()
which required class as argument and it uses this.tableClass
.
That means, column1Arguments
used this.tableClass
and this.tableName
becuase it was its table. I needed to find a way to run the same function for column2Arguments
but with it's tableClass and tableName.
I wrote code that temporarily changes both tableClass and tableName to second table, then runs a function to parse second argument and then change it back to original table class and name.
This solution works but is terrible :D I would love the original developer to implement a cleaner solution because you understand the code the best. Use this just as explanation where the bug comes from.
^ Pull request above solves my issue.
Hi, thanks for creating a PR!
The last couple of weeks I've been working on the next version, which switches from lambas to strings. I just wrote a test for your case, and this works with the new code.
Today should be the release of TypeScript 4.1. When that is final, I will release version 3.0
If you want, you can use a beta release (3.0.0-beta.4) in combination with TypeScript 4.1RC for now.
For more info, on how to upgrade to v3 check the readme on the main git page https://github.com/wwwouter/typed-knex
TypeScript v4.1 is released and so is typed-knex v3 😄
I have installed typescript 4.1 and knex 3 but I got bunch of errors. Also, let me say, in VS Code (editor) I dont see any red lines. Versions:
"typescript": "^4.1.2"
"@wwwouter/typed-knex": "^3.0.0",
Example of code:
const staticPagesP = SQLManager.typedKnex
.query(TableStaticPages)
.leftOuterJoinTableOnFunction('lang', TableStaticPagesLang, (join) => {
join.on(
(r) => r.pageIdPlain,
'=',
(r) => r.id
);
})
.select((r) => [r.lang.slug, r.lang.text, r.lang.title])
.where((r) => r.lang.langId, lang)
.getMany();
Example of error:
node_modules/@wwwouter/typed-knex/dist/src/typedKnex.d.ts:311:42
311 <PropertyType>(selectColumnFunction: (c: TransformPropsToFunctionsReturnPropertyType<NonNullableRecursive<SelectableModel>>) => () => PropertyType, value: PropertyType): ITypedQueryBuilder<Model, SelectableModel, Row>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The expected type comes from the return type of this signature.
src/api/services/PublicService.ts:242:26 - error TS2769: No overload matches this call.
Overload 1 of 4, '(selectColumnFunction: (c: TransformPropsToFunctionsReturnPropertyType<NonNullableRecursive<AddPropertyWithType<TableStaticPages, "lang", TableStaticPagesLang>>>) => () => string, value: string): ITypedQueryBuilder<...>', gave the following error.
Type 'TransformPropsToFunctionsReturnPropertyType<NonNullableRecursive<TableLangs>>' is not assignable to type '() => string'.
Overload 2 of 4, '(key: "id" | "internalName" | "lang.id" | "lang.langIdPlain" | "lang.slug" | "lang.title" | "lang.langId.code" | "lang.langId.name" | "lang.pageIdPlain" | "lang.text" | "lang.pageId.id" | "lang.pageId.internalName", value: string | number): ITypedQueryBuilder<...>', gave the following error.
Argument of type '(r: TransformPropsToFunctionsReturnPropertyType<NonNullableRecursive<AddPropertyWithType<TableStaticPages, "lang", TableStaticPagesLang>>>) => TransformPropsToFunctionsReturnPropertyType<...>' is not assignable to parameter of type '"id" | "internalName" | "lang.id" | "lang.langIdPlain" | "lang.slug" | "lang.title" | "lang.langId.code" | "lang.langId.name" | "lang.pageIdPlain" | "lang.text" | "lang.pageId.id" | "lang.pageId.internalName"'.
Type '(r: TransformPropsToFunctionsReturnPropertyType<NonNullableRecursive<AddPropertyWithType<TableStaticPages, "lang", TableStaticPagesLang>>>) => TransformPropsToFunctionsReturnPropertyType<...>' is not assignable to type '"lang.pageId.internalName"'.
242 const staticPagesP = SQLManager.typedKnex
~~~~~~~~~~~~~~~~~~~~
243 .query(TableStaticPages)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
251 .select((r) => [r.lang.slug, r.lang.text, r.lang.title])
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
252 .where((r) => r.lang.langId, lang)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@wwwouter/typed-knex/dist/src/typedKnex.d.ts:311:42
311 <PropertyType>(selectColumnFunction: (c: TransformPropsToFunctionsReturnPropertyType<NonNullableRecursive<SelectableModel>>) => () => PropertyType, value: PropertyType): ITypedQueryBuilder<Model, SelectableModel, Row>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The expected type comes from the return type of this signature.
Full error after starting server:
> fullstack-server@1.0.0 dev:api2 /Users/meldiron/Desktop/ren-sk/Server
> DEBUG=log,error,success,warn,info,knex:bindings,knex:query ts-node --files src/app.ts src/app.ts
log Connecting to DB .. +0ms
log Starting server .. +0ms
Error initializing middleware
TSError: ⨯ Unable to compile TypeScript:
src/api/services/PublicService.ts:56:33 - error TS2769: No overload matches this call.
Overload 1 of 4, '(selectColumnFunction: (c: TransformPropsToFunctionsReturnPropertyType<NonNullableRecursive<AddPropertyWithType<TableProducts, "lang", TableProductsLang>>>) => () => string, value: string): ITypedQueryBuilder<...>', gave the following error.
Type 'TransformPropsToFunctionsReturnPropertyType<NonNullableRecursive<TableLangs>>' is not assignable to type '() => string'.
Type 'TransformPropsToFunctionsReturnPropertyType<NonNullableRecursive<TableLangs>>' provides no match for the signature '(): string'.
Overload 2 of 4, '(key: "id" | "internalName" | "isDeprecated" | "isSpecialEdition" | "stock" | "price" | "weight" | "backgroundColor" | "imageIdPlain" | "imageId.id" | "imageId.title" | "imageId.description" | ... 162 more ... | "imageId.modifiedBy.role.appAccess", value: string | ... 3 more ... | Date): ITypedQueryBuilder<...>', gave the following error.
Argument of type '(r: TransformPropsToFunctionsReturnPropertyType<NonNullableRecursive<AddPropertyWithType<TableProducts, "lang", TableProductsLang>>>) => TransformPropsToFunctionsReturnPropertyType<...>' is not assignable to parameter of type '"id" | "internalName" | "isDeprecated" | "isSpecialEdition" | "stock" | "price" | "weight" | "backgroundColor" | "imageIdPlain" | "imageId.id" | "imageId.title" | "imageId.description" | ... 162 more ... | "imageId.modifiedBy.role.appAccess"'.
Type '(r: TransformPropsToFunctionsReturnPropertyType<NonNullableRecursive<AddPropertyWithType<TableProducts, "lang", TableProductsLang>>>) => TransformPropsToFunctionsReturnPropertyType<...>' is not assignable to type '"imageId.modifiedBy.role.appAccess"'.
56 const product = await SQLManager.typedKnex
~~~~~~~~~~~~~~~~~~~~
57 .query(TableProducts)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
73 .where((r) => r.id, p.productId)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
74 .where((r) => r.lang.langId, langId)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@wwwouter/typed-knex/dist/src/typedKnex.d.ts:311:42
311 <PropertyType>(selectColumnFunction: (c: TransformPropsToFunctionsReturnPropertyType<NonNullableRecursive<SelectableModel>>) => () => PropertyType, value: PropertyType): ITypedQueryBuilder<Model, SelectableModel, Row>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The expected type comes from the return type of this signature.
src/api/services/PublicService.ts:203:27 - error TS2769: No overload matches this call.
Overload 1 of 4, '(selectColumnFunction: (c: TransformPropsToFunctionsReturnPropertyType<NonNullableRecursive<TableSettingsLang>>) => () => string, value: string): ITypedQueryBuilder<...>', gave the following error.
Type 'TransformPropsToFunctionsReturnPropertyType<NonNullableRecursive<TableLangs>>' is not assignable to type '() => string'.
Overload 2 of 4, '(key: "id" | "langIdPlain" | "langId.code" | "langId.name" | "settingIdPlain" | "presskitIdPlain" | "contactEmail" | "contactPhone" | "contactAddress" | "contactInfo" | "shopAlertTitle" | ... 453 more ... | "indexBox3ImageId.modifiedBy.role.appAccess", value: string | ... 3 more ... | Date): ITypedQueryBuilder<...>', gave the following error.
Argument of type '(r: TransformPropsToFunctionsReturnPropertyType<NonNullableRecursive<TableSettingsLang>>) => TransformPropsToFunctionsReturnPropertyType<...>' is not assignable to parameter of type '"id" | "langIdPlain" | "langId.code" | "langId.name" | "settingIdPlain" | "presskitIdPlain" | "contactEmail" | "contactPhone" | "contactAddress" | "contactInfo" | "shopAlertTitle" | ... 453 more ... | "indexBox3ImageId.modifiedBy.role.appAccess"'.
Type '(r: TransformPropsToFunctionsReturnPropertyType<NonNullableRecursive<TableSettingsLang>>) => TransformPropsToFunctionsReturnPropertyType<...>' is not assignable to type '"indexBox3ImageId.modifiedBy.role.appAccess"'.
203 const settingsLangP = SQLManager.typedKnex
~~~~~~~~~~~~~~~~~~~~
204 .query(TableSettingsLang)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
238 ])
~~~~~~~~
239 .where((r) => r.langId, lang)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@wwwouter/typed-knex/dist/src/typedKnex.d.ts:311:42
311 <PropertyType>(selectColumnFunction: (c: TransformPropsToFunctionsReturnPropertyType<NonNullableRecursive<SelectableModel>>) => () => PropertyType, value: PropertyType): ITypedQueryBuilder<Model, SelectableModel, Row>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The expected type comes from the return type of this signature.
src/api/services/PublicService.ts:242:26 - error TS2769: No overload matches this call.
Overload 1 of 4, '(selectColumnFunction: (c: TransformPropsToFunctionsReturnPropertyType<NonNullableRecursive<AddPropertyWithType<TableStaticPages, "lang", TableStaticPagesLang>>>) => () => string, value: string): ITypedQueryBuilder<...>', gave the following error.
Type 'TransformPropsToFunctionsReturnPropertyType<NonNullableRecursive<TableLangs>>' is not assignable to type '() => string'.
Overload 2 of 4, '(key: "id" | "internalName" | "lang.id" | "lang.langIdPlain" | "lang.slug" | "lang.title" | "lang.langId.code" | "lang.langId.name" | "lang.pageIdPlain" | "lang.text" | "lang.pageId.id" | "lang.pageId.internalName", value: string | number): ITypedQueryBuilder<...>', gave the following error.
Argument of type '(r: TransformPropsToFunctionsReturnPropertyType<NonNullableRecursive<AddPropertyWithType<TableStaticPages, "lang", TableStaticPagesLang>>>) => TransformPropsToFunctionsReturnPropertyType<...>' is not assignable to parameter of type '"id" | "internalName" | "lang.id" | "lang.langIdPlain" | "lang.slug" | "lang.title" | "lang.langId.code" | "lang.langId.name" | "lang.pageIdPlain" | "lang.text" | "lang.pageId.id" | "lang.pageId.internalName"'.
Type '(r: TransformPropsToFunctionsReturnPropertyType<NonNullableRecursive<AddPropertyWithType<TableStaticPages, "lang", TableStaticPagesLang>>>) => TransformPropsToFunctionsReturnPropertyType<...>' is not assignable to type '"lang.pageId.internalName"'.
242 const staticPagesP = SQLManager.typedKnex
~~~~~~~~~~~~~~~~~~~~
243 .query(TableStaticPages)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
251 .select((r) => [r.lang.slug, r.lang.text, r.lang.title])
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
252 .where((r) => r.lang.langId, lang)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@wwwouter/typed-knex/dist/src/typedKnex.d.ts:311:42
311 <PropertyType>(selectColumnFunction: (c: TransformPropsToFunctionsReturnPropertyType<NonNullableRecursive<SelectableModel>>) => () => PropertyType, value: PropertyType): ITypedQueryBuilder<Model, SelectableModel, Row>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The expected type comes from the return type of this signature.
src/api/services/PublicService.ts:260:18 - error TS2769: No overload matches this call.
Overload 1 of 4, '(selectColumnFunction: (c: TransformPropsToFunctionsReturnPropertyType<NonNullableRecursive<AddPropertyWithType<TableFaq, "lang", TableFaqLang>>>) => () => string, value: string): ITypedQueryBuilder<...>', gave the following error.
Type 'TransformPropsToFunctionsReturnPropertyType<NonNullableRecursive<TableLangs>>' is not assignable to type '() => string'.
Overload 2 of 4, '(key: "id" | "internalName" | "lang.id" | "lang.langIdPlain" | "lang.langId.code" | "lang.langId.name" | "lang.faqIdPlain" | "lang.question" | "lang.answer" | "lang.faqId.id" | "lang.faqId.internalName", value: string | number): ITypedQueryBuilder<...>', gave the following error.
Argument of type '(r: TransformPropsToFunctionsReturnPropertyType<NonNullableRecursive<AddPropertyWithType<TableFaq, "lang", TableFaqLang>>>) => TransformPropsToFunctionsReturnPropertyType<...>' is not assignable to parameter of type '"id" | "internalName" | "lang.id" | "lang.langIdPlain" | "lang.langId.code" | "lang.langId.name" | "lang.faqIdPlain" | "lang.question" | "lang.answer" | "lang.faqId.id" | "lang.faqId.internalName"'.
Type '(r: TransformPropsToFunctionsReturnPropertyType<NonNullableRecursive<AddPropertyWithType<TableFaq, "lang", TableFaqLang>>>) => TransformPropsToFunctionsReturnPropertyType<...>' is not assignable to type '"lang.faqId.internalName"'.
260 const faqP = SQLManager.typedKnex
~~~~~~~~~~~~~~~~~~~~
261 .query(TableFaq)
~~~~~~~~~~~~~~~~~~~~~~
...
269 .select((r) => [r.lang.answer, r.lang.question])
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
270 .where((r) => r.lang.langId, lang)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@wwwouter/typed-knex/dist/src/typedKnex.d.ts:311:42
311 <PropertyType>(selectColumnFunction: (c: TransformPropsToFunctionsReturnPropertyType<NonNullableRecursive<SelectableModel>>) => () => PropertyType, value: PropertyType): ITypedQueryBuilder<Model, SelectableModel, Row>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The expected type comes from the return type of this signature.
src/api/services/PublicService.ts:273:28 - error TS2769: No overload matches this call.
Overload 1 of 4, '(selectColumnFunction: (c: TransformPropsToFunctionsReturnPropertyType<NonNullableRecursive<AddPropertyWithType<TableAboutSections, "lang", TableAboutSectionsLang>>>) => () => string, value: string): ITypedQueryBuilder<...>', gave the following error.
Type 'TransformPropsToFunctionsReturnPropertyType<NonNullableRecursive<TableLangs>>' is not assignable to type '() => string'.
Overload 2 of 4, '(key: "id" | "internalName" | "imageIdPlain" | "imageId.id" | "imageId.title" | "imageId.description" | "imageId.storage" | "imageId.filenameDisk" | "imageId.filenameDownload" | ... 302 more ... | "smallImageId.modifiedBy.role.appAccess", value: string | ... 3 more ... | Date): ITypedQueryBuilder<...>', gave the following error.
Argument of type '(r: TransformPropsToFunctionsReturnPropertyType<NonNullableRecursive<AddPropertyWithType<TableAboutSections, "lang", TableAboutSectionsLang>>>) => TransformPropsToFunctionsReturnPropertyType<...>' is not assignable to parameter of type '"id" | "internalName" | "imageIdPlain" | "imageId.id" | "imageId.title" | "imageId.description" | "imageId.storage" | "imageId.filenameDisk" | "imageId.filenameDownload" | ... 302 more ... | "smallImageId.modifiedBy.role.appAccess"'.
Type '(r: TransformPropsToFunctionsReturnPropertyType<NonNullableRecursive<AddPropertyWithType<TableAboutSections, "lang", TableAboutSectionsLang>>>) => TransformPropsToFunctionsReturnPropertyType<...>' is not assignable to type '"smallImageId.modifiedBy.role.appAccess"'.
273 const aboutSectionsP = SQLManager.typedKnex
~~~~~~~~~~~~~~~~~~~~
274 .query(TableAboutSections)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
291 ])
~~~~~~~~
292 .where((r) => r.lang.langId, lang)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@wwwouter/typed-knex/dist/src/typedKnex.d.ts:311:42
311 <PropertyType>(selectColumnFunction: (c: TransformPropsToFunctionsReturnPropertyType<NonNullableRecursive<SelectableModel>>) => () => PropertyType, value: PropertyType): ITypedQueryBuilder<Model, SelectableModel, Row>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The expected type comes from the return type of this signature.
src/api/services/PublicService.ts:295:22 - error TS2769: No overload matches this call.
Overload 1 of 4, '(selectColumnFunction: (c: TransformPropsToFunctionsReturnPropertyType<NonNullableRecursive<AddPropertyWithType<TableReviews, "lang", TableReviewsLang>>>) => () => string, value: string): ITypedQueryBuilder<...>', gave the following error.
Type 'TransformPropsToFunctionsReturnPropertyType<NonNullableRecursive<TableLangs>>' is not assignable to type '() => string'.
Overload 2 of 4, '(key: "id" | "internalName" | "imageIdPlain" | "imageId.id" | "imageId.title" | "imageId.description" | "imageId.storage" | "imageId.filenameDisk" | "imageId.filenameDownload" | ... 149 more ... | "lang.reviewId.imageId.modifiedBy.lastPage", value: string | ... 3 more ... | Date): ITypedQueryBuilder<...>', gave the following error.
Argument of type '(r: TransformPropsToFunctionsReturnPropertyType<NonNullableRecursive<AddPropertyWithType<TableReviews, "lang", TableReviewsLang>>>) => TransformPropsToFunctionsReturnPropertyType<...>' is not assignable to parameter of type '"id" | "internalName" | "imageIdPlain" | "imageId.id" | "imageId.title" | "imageId.description" | "imageId.storage" | "imageId.filenameDisk" | "imageId.filenameDownload" | ... 149 more ... | "lang.reviewId.imageId.modifiedBy.lastPage"'.
Type '(r: TransformPropsToFunctionsReturnPropertyType<NonNullableRecursive<AddPropertyWithType<TableReviews, "lang", TableReviewsLang>>>) => TransformPropsToFunctionsReturnPropertyType<...>' is not assignable to type '"lang.reviewId.imageId.modifiedBy.lastPage"'.
295 const reviewsP = SQLManager.typedKnex
~~~~~~~~~~~~~~~~~~~~
296 .query(TableReviews)
~~~~~~~~~~~~~~~~~~~~~~~~~~
...
305 .select((r) => [r.imageIdPlain, r.lang.name, r.lang.text])
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
306 .where((r) => r.lang.langId, lang)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@wwwouter/typed-knex/dist/src/typedKnex.d.ts:311:42
311 <PropertyType>(selectColumnFunction: (c: TransformPropsToFunctionsReturnPropertyType<NonNullableRecursive<SelectableModel>>) => () => PropertyType, value: PropertyType): ITypedQueryBuilder<Model, SelectableModel, Row>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The expected type comes from the return type of this signature.
src/api/services/PublicService.ts:309:23 - error TS2769: No overload matches this call.
Overload 1 of 4, '(selectColumnFunction: (c: TransformPropsToFunctionsReturnPropertyType<NonNullableRecursive<AddPropertyWithType<TableProducts, "lang", TableProductsLang>>>) => () => string, value: string): ITypedQueryBuilder<...>', gave the following error.
Type 'TransformPropsToFunctionsReturnPropertyType<NonNullableRecursive<TableLangs>>' is not assignable to type '() => string'.
Overload 2 of 4, '(key: "id" | "internalName" | "isDeprecated" | "isSpecialEdition" | "stock" | "price" | "weight" | "backgroundColor" | "imageIdPlain" | "imageId.id" | "imageId.title" | "imageId.description" | ... 162 more ... | "imageId.modifiedBy.role.appAccess", value: string | ... 3 more ... | Date): ITypedQueryBuilder<...>', gave the following error.
Argument of type '(r: TransformPropsToFunctionsReturnPropertyType<NonNullableRecursive<AddPropertyWithType<TableProducts, "lang", TableProductsLang>>>) => TransformPropsToFunctionsReturnPropertyType<...>' is not assignable to parameter of type '"id" | "internalName" | "isDeprecated" | "isSpecialEdition" | "stock" | "price" | "weight" | "backgroundColor" | "imageIdPlain" | "imageId.id" | "imageId.title" | "imageId.description" | ... 162 more ... | "imageId.modifiedBy.role.appAccess"'.
Type '(r: TransformPropsToFunctionsReturnPropertyType<NonNullableRecursive<AddPropertyWithType<TableProducts, "lang", TableProductsLang>>>) => TransformPropsToFunctionsReturnPropertyType<...>' is not assignable to type '"imageId.modifiedBy.role.appAccess"'.
309 const productsP = SQLManager.typedKnex
~~~~~~~~~~~~~~~~~~~~
310 .query(TableProducts)
~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
334 ])
~~~~~~~~
335 .where((r) => r.lang.langId, lang)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@wwwouter/typed-knex/dist/src/typedKnex.d.ts:311:42
311 <PropertyType>(selectColumnFunction: (c: TransformPropsToFunctionsReturnPropertyType<NonNullableRecursive<SelectableModel>>) => () => PropertyType, value: PropertyType): ITypedQueryBuilder<Model, SelectableModel, Row>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The expected type comes from the return type of this signature.
src/api/services/PublicService.ts:488:38 - error TS2769: No overload matches this call.
Overload 1 of 4, '(selectColumnFunction: (c: TransformPropsToFunctionsReturnPropertyType<NonNullableRecursive<AddPropertyWithType<TableAboutSectionsPoints, "lang", TableAboutSectionsPointsLang>>>) => () => string, value: string): ITypedQueryBuilder<...>', gave the following error.
Type 'TransformPropsToFunctionsReturnPropertyType<NonNullableRecursive<TableLangs>>' is not assignable to type '() => string'.
Overload 2 of 4, '(key: "id" | "internalName" | "lang.id" | "lang.langIdPlain" | "lang.langId.code" | "lang.langId.name" | "lang.text" | "sectionIdPlain" | "sectionId.id" | "sectionId.internalName" | ... 221 more ... | "sectionId.smallImageId.modifiedBy.role.appAccess", value: string | ... 3 more ... | Date): ITypedQueryBuilder<...>', gave the following error.
Argument of type '(r2: TransformPropsToFunctionsReturnPropertyType<NonNullableRecursive<AddPropertyWithType<TableAboutSectionsPoints, "lang", TableAboutSectionsPointsLang>>>) => TransformPropsToFunctionsReturnPropertyType<...>' is not assignable to parameter of type '"id" | "internalName" | "lang.id" | "lang.langIdPlain" | "lang.langId.code" | "lang.langId.name" | "lang.text" | "sectionIdPlain" | "sectionId.id" | "sectionId.internalName" | ... 221 more ... | "sectionId.smallImageId.modifiedBy.role.appAccess"'.
Type '(r2: TransformPropsToFunctionsReturnPropertyType<NonNullableRecursive<AddPropertyWithType<TableAboutSectionsPoints, "lang", TableAboutSectionsPointsLang>>>) => TransformPropsToFunctionsReturnPropertyType<...>' is not assignable to type '"sectionId.smallImageId.modifiedBy.role.appAccess"'.
488 const points = await SQLManager.typedKnex
~~~~~~~~~~~~~~~~~~~~
489 .query(TableAboutSectionsPoints)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
502 .where((r2) => r2.sectionIdPlain, r.id)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
503 .where((r2) => r2.lang.langId, lang)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@wwwouter/typed-knex/dist/src/typedKnex.d.ts:311:42
311 <PropertyType>(selectColumnFunction: (c: TransformPropsToFunctionsReturnPropertyType<NonNullableRecursive<SelectableModel>>) => () => PropertyType, value: PropertyType): ITypedQueryBuilder<Model, SelectableModel, Row>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The expected type comes from the return type of this signature.
at createTSError (/usr/local/lib/node_modules/ts-node/src/index.ts:500:12)
at reportTSError (/usr/local/lib/node_modules/ts-node/src/index.ts:504:19)
at getOutput (/usr/local/lib/node_modules/ts-node/src/index.ts:739:36)
at Object.compile (/usr/local/lib/node_modules/ts-node/src/index.ts:955:32)
at Module.m._compile (/usr/local/lib/node_modules/ts-node/src/index.ts:1043:43)
at Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Object.require.extensions.<computed> [as .ts] (/usr/local/lib/node_modules/ts-node/src/index.ts:1046:12)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Module.require (internal/modules/cjs/loader.js:1025:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/Users/meldiron/Desktop/ren-sk/Server/src/api/controllers/publicCtrl.ts:6:1)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Module.m._compile (/usr/local/lib/node_modules/ts-node/src/index.ts:1043:23)
at Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Object.require.extensions.<computed> [as .ts] (/usr/local/lib/node_modules/ts-node/src/index.ts:1046:12)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! fullstack-server@1.0.0 dev:api2: `DEBUG=log,error,success,warn,info,knex:bindings,knex:query ts-node --files src/app.ts src/app.ts`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the fullstack-server@1.0.0 dev:api2 script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/meldiron/.npm/_logs/2020-11-24T09_27_34_603Z-debug.log
[nodemon] app crashed - waiting for file changes before starting...
Nevermind, it was bug in my code. .where((r) => r.lang.langId, lang)
should be langIdPlain
instead of langId
. langId is object refering to different table while langIdPlain is number. Although, it is weird it didnt show the error in VS Code. I though there was some versioning missmatch between Typescript, TS-Node and typedKnex.
Anyway, it works and the original joining problem is resolved. Thanks <3
Issue type:
[X] Question [X] Bug report [ ] Feature request [ ] Documentation issue
Database system/driver:
[ ] Postgres [ ] MSSQL [X] MySQL [ ] MariaDB [ ] SQLite3 [ ] Oracle [ ] Amazon Redshift
typed-knex version:
[X]
latest
[ ]@next
[ ]0.x.x
(or put your version here)Description:
My definitions:
My code:
Result:
Generated query:
What I wanted:
I guess everything is correct exccept the
pageIdPlain
needs topage_id
as configured using @Column. Or am I using it incorrectly?