Dito.js is a declarative and modern web framework with a focus on API driven development, based on Objection.js, Koa.js and Vue.js – Developed at Lineto by Jürg Lehni and made available by Lineto in 2018 under the MIT license
We have fixed most server typings, but one problem remains.
Running yarn types in the server package prints:
➜ server git:(master) ✗ yarn types
types/index.d.ts:1838:33 - error TS2536: Type '$Key' cannot be used to index type 'T'.
1838 [$Key in SelectModelKeys<T>]: T[$Key] extends Model
~~~~~~~
types/index.d.ts:1839:29 - error TS2536: Type '$Key' cannot be used to index type 'T'.
1839 ? SelectModelProperties<T[$Key]>
~~~~~~~
types/index.d.ts:1840:7 - error TS2536: Type '$Key' cannot be used to index type 'T'.
1840 : T[$Key]
~~~~~~~
This is all due to the following types:
export type SelectModelProperties<T> = {
[$Key in SelectModelKeys<T>]: T[$Key] extends Model
? SelectModelProperties<T[$Key]>
: T[$Key]
}
export type SelectModelKeys<T> = AnyGate<
T,
Exclude<
keyof ConditionalExcept<T, Function>,
| `$${string}`
| 'QueryBuilderType'
| 'foreignKeyId'
>,
string
>
What I find interesting is that this all looks quite similar to what Objection.js does with ModelObject and DataPropertyNames.
I have played around with these and have managed to make the errors go away, but I am not certain if it's right:
We have fixed most server typings, but one problem remains.
Running
yarn types
in the server package prints:This is all due to the following types:
What I find interesting is that this all looks quite similar to what Objection.js does with
ModelObject
andDataPropertyNames
.I have played around with these and have managed to make the errors go away, but I am not certain if it's right:
@puckey could you take a look?