{"action":"created","issue":{"url":"https://api.github.com/repos/DefinitelyTyped/DefinitelyTyped/issues/12943","repository_url":"https://api.github.com/repos/DefinitelyTyped/DefinitelyTyped","labels_url":"https://api.github.com/repos/DefinitelyTyped/DefinitelyTyped/issues/12943/labels{/name}","comments_url":"https://api.github.com/repos/DefinitelyTyped/DefinitelyTyped/issues/12943/comments","events_url":"https://api.github.com/repos/DefinitelyTyped/DefinitelyTyped/issues/12943/events","html_url":"https://github.com/DefinitelyTyped/DefinitelyTyped/issues/12943","id":191882666,"number":12943,"title":"Mongoose missed error signature in schema.post('save', fn(error, doc, next) {}) middleware","user":{"login":"valeriy-devpronet","id":11663800,"avatar_url":"https://avatars.githubusercontent.com/u/11663800?v=3","gravatar_id":"","url":"https://api.github.com/users/valeriy-devpronet","html_url":"https://github.com/valeriy-devpronet","followers_url":"https://api.github.com/users/valeriy-devpronet/followers","following_url":"https://api.github.com/users/valeriy-devpronet/following{/other_user}","gists_url":"https://api.github.com/users/valeriy-devpronet/gists{/gist_id}","starred_url":"https://api.github.com/users/valeriy-devpronet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/valeriy-devpronet/subscriptions","organizations_url":"https://api.github.com/users/valeriy-devpronet/orgs","repos_url":"https://api.github.com/users/valeriy-devpronet/repos","events_url":"https://api.github.com/users/valeriy-devpronet/events{/privacy}","received_events_url":"https://api.github.com/users/valeriy-devpronet/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":12,"created_at":"2016-11-27T20:16:27Z","updated_at":"2016-12-01T15:36:16Z","closed_at":null,"body":"- [ x ] I tried using the latest `mongoose/mongoose.d.ts` `\"@types/mongoose\": \"^4.6.1\"` file in this repo and had problems.\r\n- [ x ] I tried using the latest stable version of tsc. https://www.npmjs.com/package/typescript\r\n- [ x ] I want to talk about `mongoose/mongoose.d.ts`.\r\n  - The authors of that type definition are cc/ @simonxca\r\n\r\nHi, there is the problem with mongoose middleware definitions:\r\nAccording to the docs http://mongoosejs.com/docs/middleware.html function signature for the hook post save is may looks like this (error: MongoError, doc: Document, next: (err?: NativeError) => void)\r\n```javascript\r\nschema.post('save', function(error, doc, next) {\r\n  if (error.name === 'MongoError' && error.code === 11000) {\r\n    next(new Error('There was a duplicate key error'));\r\n  } else {\r\n    next(error);\r\n  }\r\n});\r\n\r\n```\r\n\r\nBut typings has this\r\n\r\n```javascript\r\n    /**\r\n     * Defines a post hook for the document\r\n     * Post hooks fire on the event emitted from document instances of Models compiled\r\n     *   from this schema.\r\n     * @param method name of the method to hook\r\n     * @param fn callback\r\n     */\r\n    post<T extends Document>(method: string, fn: (doc: T, next: (err?: NativeError) => void,\r\n      ...otherArgs: any[]) => void): this;\r\n    post<T extends Document>(method: string, fn: (doc: T) => void, ...args: any[]): this;\r\n```\r\n\r\nin other words, `error` signature was omitted"},"comment":{"url":"https://api.github.com/repos/DefinitelyTyped/DefinitelyTyped/issues/comments/264205392","html_url":"https://github.com/DefinitelyTyped/DefinitelyTyped/issues/12943#issuecomment-264205392","issue_url":"https://api.github.com/repos/DefinitelyTyped/DefinitelyTyped/issues/12943","id":264205392,"user":{"login":"valeriy-devpronet","id":11663800,"avatar_url":"https://avatars.githubusercontent.com/u/11663800?v=3","gravatar_id":"","url":"https://api.github.com/users/valeriy-devpronet","html_url":"https://github.com/valeriy-devpronet","followers_url":"https://api.github.com/users/valeriy-devpronet/followers","following_url":"https://api.github.com/users/valeriy-devpronet/following{/other_user}","gists_url":"https://api.github.com/users/valeriy-devpronet/gists{/gist_id}","starred_url":"https://api.github.com/users/valeriy-devpronet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/valeriy-devpronet/subscriptions","organizations_url":"https://api.github.com/users/valeriy-devpronet/orgs","repos_url":"https://api.github.com/users/valeriy-devpronet/repos","events_url":"https://api.github.com/users/valeriy-devpronet/events{/privacy}","received_events_url":"https://api.github.com/users/valeriy-devpronet/received_events","type":"User","site_admin":false},"created_at":"2016-12-01T15:36:16Z","updated_at":"2016-12-01T15:36:16Z","body":"@simonxca  Ok, than I think the problem is solved. If you are agree with me than you can close the ticket)\r\n\r\nThanks"}}
{"actor":{"display_login":"valeriy-devpronet"}}