Closed gchokeen closed 2 years ago
@gchokeen workaround, edit the file in node_modules:
options: MongooseServiceOptions<Document<any, any, any>>;
Fixed in v8.4.1
The changes in #413 where reverted by https://github.com/feathersjs-ecosystem/feathers-mongoose/pull/414/files#diff-093ad82a25aee498b11febf1cdcb6546e4d223ffcb49ed69cc275ac27ce0ccceL24-R24. This problem still occurs.
@daffl please reopen
These changes are backwards compatible as suggested by the linter. I was not able to reproduce the original error.
Apologies, I was looking at the wrong line of code. This should indeed be fixed.
Workaround, either do a manual edit of the file in node_modules.
options: MongooseServiceOptions<Document<any, any, any>>;
Or, if you are like me, stuck on it being installed when deploying the code. Do this:
Add a directory called lib-types
to the source of your project.
mkdir lib-types
Create a directory with the name of the library inside this new directory.
cd lib-types && mkdir feathers-mongoose
Create a file with the name index.d.ts
inside this new directory.
cd feathers-mongoose && touch index.d.ts
Copy this content inside the file:
// TypeScript Version: 4.0
import { AdapterService, InternalServiceMethods, ServiceOptions } from '@feathersjs/adapter-commons';
import { Hook, Id, NullableId, Paginated, Params } from '@feathersjs/feathers';
import { Document, Model } from 'mongoose';
export namespace hooks {
function toObject(options?: any, dataField?: string): Hook;
}
export namespace transactionManager {
const beginTransaction: Hook;
const commitTransaction: Hook;
const rollbackTransaction: Hook;
}
export interface MongooseServiceOptions<T extends Document = any> extends ServiceOptions {
Model: Model<T>;
lean: boolean;
overwrite: boolean;
useEstimatedDocumentCount: boolean;
}
export class Service<T = any> extends AdapterService<T> implements InternalServiceMethods<T> {
Model: Model<Document>;
/*
* This line has been manually changed for the workaround
*/
options: MongooseServiceOptions<Document<any, any, any>>;
constructor(config?: Partial<MongooseServiceOptions>);
_find(params?: Params): Promise<T | T[] | Paginated<T>>;
_get(id: Id, params?: Params): Promise<T>;
_create(data: Partial<T> | Array<Partial<T>>, params?: Params): Promise<T | T[]>;
_update(id: NullableId, data: T, params?: Params): Promise<T>;
_patch(id: NullableId, data: Partial<T>, params?: Params): Promise<T>;
_remove(id: NullableId, params?: Params): Promise<T>;
}
declare const mongoose: ((config?: Partial<MongooseServiceOptions>) => Service);
export default mongoose;
In your tsconfig.json, add the lib-types
directory to the paths property.
{
"compilerOptions": {
"target": "es2018",
"module": "commonjs",
"outDir": "./lib",
"rootDir": "./src",
"strict": true,
"esModuleInterop": true,
"paths": {
"*": ["./*", "./lib-types/*"]
}
},
"exclude": ["test"]
}
Ok, this should be actually fixed in v8.4.2. Thank you for the PR @bartduisters!
https://github.com/feathersjs-ecosystem/feathers-mongoose/blob/0bda68806378dabc4c91b6a7005f72a2e49f5d19/types/index.d.ts#L25
I'm using feathers 4.5.11 and feathers-mongoose 8.4.0, on the fresh feathers generate application, I'm getting the bellow type error from feathers-mongoose package type definition
Whole package dependencies
Thanks Gowri