-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
type definition error on MongooseServiceOptions<T & Document> #412
Comments
@gchokeen workaround, edit the file in node_modules:
|
This could be fixed with a pull request. You can edit the file here |
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.
Or, if you are like me, stuck on it being installed when deploying the code. Do this: Add a directory called 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 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 {
"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! |
feathers-mongoose/types/index.d.ts
Line 25 in 0bda688
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
The text was updated successfully, but these errors were encountered: