Closed SeveHo closed 3 years ago
I had the same issue using the Objection driver which also utilises Knex. To fix it you should just need to change the import statement in src/models/users.model.ts from import Knex from 'knex';
to import {Knex} from 'knex';
.
Of course this doesn't change whats created via the CLI but should allow it all to compile in the meantime.
This seems to be an issue with the feathers-knex library as well. Not only the generator's output. I get these errors when compiling:
node_modules/feathers-knex/types/index.d.ts:8:10 - error TS2709: Cannot use namespace 'Knex' as a type.
8 Model: Knex;
~~~~
node_modules/feathers-knex/types/index.d.ts:15:64 - error TS2709: Cannot use namespace 'Knex' as a type.
15 function start(options?: { getKnex: (hook: HookContext) => Knex | undefined }): Hook;
~~~~
node_modules/feathers-knex/types/index.d.ts:22:10 - error TS2709: Cannot use namespace 'Knex' as a type.
22 Model: Knex;
~~~~
node_modules/feathers-knex/types/index.d.ts:23:9 - error TS2709: Cannot use namespace 'Knex' as a type.
23 knex: Knex;
~~~~
node_modules/feathers-knex/types/index.d.ts:29:24 - error TS2709: Cannot use namespace 'Knex' as a type.
29 db(params?: Params): Knex;
~~~~
node_modules/feathers-knex/types/index.d.ts:31:33 - error TS2709: Cannot use namespace 'Knex' as a type.
31 createQuery(params?: Params): Knex;
~~~~
Downgrading to a pre 0.95.0 version of Knex solves the issue.
I am also having this issue.
Temperary solution:
Edit tsconfig.json
{
"compilerOptions": {
"skipLibCheck": true
}
}
Steps to reproduce
Generated a clean app with TypeScript enabled
feathers generate app
Generate a new service with
feathers generate service
and choose KnexJS as service typeExpected behavior
When starting the app (nom start) tsc should compile successfully.
Actual behavior
Lots of errors about Knex namespace. E.g:
System configuration
Module versions (especially the part that's not working):
NodeJS version: 15.14.0
Operating System: macOS Big Sur 11.2