{"action":"created","issue":{"url":"https://api.github.com/repos/DefinitelyTyped/DefinitelyTyped/issues/10110","repository_url":"https://api.github.com/repos/DefinitelyTyped/DefinitelyTyped","labels_url":"https://api.github.com/repos/DefinitelyTyped/DefinitelyTyped/issues/10110/labels{/name}","comments_url":"https://api.github.com/repos/DefinitelyTyped/DefinitelyTyped/issues/10110/comments","events_url":"https://api.github.com/repos/DefinitelyTyped/DefinitelyTyped/issues/10110/events","html_url":"https://github.com/DefinitelyTyped/DefinitelyTyped/issues/10110","id":165468206,"number":10110,"title":"Recent updates to mongoose.d.ts broke use of interfaces on model compilation","user":{"login":"Ruroni","id":2055181,"avatar_url":"https://avatars.githubusercontent.com/u/2055181?v=3","gravatar_id":"","url":"https://api.github.com/users/Ruroni","html_url":"https://github.com/Ruroni","followers_url":"https://api.github.com/users/Ruroni/followers","following_url":"https://api.github.com/users/Ruroni/following{/other_user}","gists_url":"https://api.github.com/users/Ruroni/gists{/gist_id}","starred_url":"https://api.github.com/users/Ruroni/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ruroni/subscriptions","organizations_url":"https://api.github.com/users/Ruroni/orgs","repos_url":"https://api.github.com/users/Ruroni/repos","events_url":"https://api.github.com/users/Ruroni/events{/privacy}","received_events_url":"https://api.github.com/users/Ruroni/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":34,"created_at":"2016-07-14T03:25:39Z","updated_at":"2016-09-16T23:18:48Z","closed_at":"2016-07-15T04:22:28Z","body":"- [x] I tried using the latest `mongoose/mongoose.d.ts` file in this repo and had problems.\r\n  - The authors of that type definition are @simonxca in #10084.\r\n\r\nBasically this broke my use of mongoose. Not that I am sure I was using it correctly as I'm a bit of a novice in this TS/JS realm.\r\n\r\nSnippet:\r\n```\r\n{...}\r\ninterface Location extends mongoose.Document {\r\n  name: string;\r\n  address: string;\r\n  rating: number;\r\n  facilities: string[];\r\n  coords: number[];\r\n  openingTimes: any[];\r\n  reviews: any[];\r\n};\r\nconst locationSchema = new mongoose.Schema({\r\n  name: { type: String, required: true },\r\n  address: String,\r\n  rating: { type: Number, \"default\": 0, min: 0, max: 5 },\r\n  facilities: [String],\r\n  coords: { type: [Number], index: \"2dsphere\" },\r\n  openingTimes: [openingTimeSchema],\r\n  reviews: [reviewSchema]\r\n});\r\n\r\nmongoose.model<Location>(\"Location\", locationSchema);\r\n{...}\r\n```\r\n\r\nSo I can no longer specify the interface with additional properties within <>. \r\n\r\n> Supplied parameters do not match the signature of the call target.\r\n\r\nSimplifying to:\r\n\r\n`mongoose.model(\"Location\", locationSchema);`\r\n\r\nWorks of course, but now in my controllers when executing a query and explicitly trying to access a property of a document TS is unaware of the additional properties on a document.\r\n\r\n```\r\nloc\r\n    .findById(req.params.locationid)\r\n    .select(\"-reviews -rating\")\r\n    .exec(\r\n      (err, location) => {\r\n        if (!location) {\r\n          sendJsonResponse(res, 404, {\r\n            \"message\": \"locationid not found\"\r\n          });\r\n          return;\r\n        } else if (err) {\r\n          sendJsonResponse(res, 400, err);\r\n          return;\r\n        }\r\n        location.name = req.body.name;\r\n        location.address = req.body.address;\r\n{...}\r\n```\r\n\r\n> Property 'name' does not exist on type '_Model & EventEmitter'.\r\n\r\nThen I thought perhaps creating a class that extends mongoose and implements my interface would work, but then I have to provide an implementation for everything in my interface and mongoose.Document. That seems kind of asinine so I figure I must be missing the most obvious way to do this.\r\n\r\nThoughts?\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/DefinitelyTyped/DefinitelyTyped/issues/comments/247730366","html_url":"https://github.com/DefinitelyTyped/DefinitelyTyped/issues/10110#issuecomment-247730366","issue_url":"https://api.github.com/repos/DefinitelyTyped/DefinitelyTyped/issues/10110","id":247730366,"user":{"login":"simonxca","id":10586163,"avatar_url":"https://avatars.githubusercontent.com/u/10586163?v=3","gravatar_id":"","url":"https://api.github.com/users/simonxca","html_url":"https://github.com/simonxca","followers_url":"https://api.github.com/users/simonxca/followers","following_url":"https://api.github.com/users/simonxca/following{/other_user}","gists_url":"https://api.github.com/users/simonxca/gists{/gist_id}","starred_url":"https://api.github.com/users/simonxca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simonxca/subscriptions","organizations_url":"https://api.github.com/users/simonxca/orgs","repos_url":"https://api.github.com/users/simonxca/repos","events_url":"https://api.github.com/users/simonxca/events{/privacy}","received_events_url":"https://api.github.com/users/simonxca/received_events","type":"User","site_admin":false},"created_at":"2016-09-16T23:18:48Z","updated_at":"2016-09-16T23:18:48Z","body":"@camilleblanc sorry was busy this week. Looks like it gets auto-updated from what I've read, but doesn't look like mongoose is up to date. I followed up with them here: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/11210#issuecomment-247729698"}}
{"actor":{"display_login":"simonxca"}}