{"action":"created","issue":{"url":"https://api.github.com/repos/crcn/sift.js/issues/135","repository_url":"https://api.github.com/repos/crcn/sift.js","labels_url":"https://api.github.com/repos/crcn/sift.js/issues/135/labels{/name}","comments_url":"https://api.github.com/repos/crcn/sift.js/issues/135/comments","events_url":"https://api.github.com/repos/crcn/sift.js/issues/135/events","html_url":"https://github.com/crcn/sift.js/pull/135","id":297412703,"number":135,"title":"fix(typescript): Fixes tslint issues.","user":{"login":"ryansmith94","id":3045513,"avatar_url":"https://avatars0.githubusercontent.com/u/3045513?v=4","gravatar_id":"","url":"https://api.github.com/users/ryansmith94","html_url":"https://github.com/ryansmith94","followers_url":"https://api.github.com/users/ryansmith94/followers","following_url":"https://api.github.com/users/ryansmith94/following{/other_user}","gists_url":"https://api.github.com/users/ryansmith94/gists{/gist_id}","starred_url":"https://api.github.com/users/ryansmith94/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryansmith94/subscriptions","organizations_url":"https://api.github.com/users/ryansmith94/orgs","repos_url":"https://api.github.com/users/ryansmith94/repos","events_url":"https://api.github.com/users/ryansmith94/events{/privacy}","received_events_url":"https://api.github.com/users/ryansmith94/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-02-15T11:28:19Z","updated_at":"2018-02-15T11:40:27Z","closed_at":null,"author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/crcn/sift.js/pulls/135","html_url":"https://github.com/crcn/sift.js/pull/135","diff_url":"https://github.com/crcn/sift.js/pull/135.diff","patch_url":"https://github.com/crcn/sift.js/pull/135.patch"},"body":"Fixes these TypeScript compilation errors in newer versions of TypeScript. Please merge asap @crcn, this will break everyone's TypeScript builds.\r\n\r\n```\r\nnode_modules/sift/index.d.ts(22,54): error TS2344: Type 'T[0][index]' does not satisfy the constraint 'any[]'.\r\nnode_modules/sift/index.d.ts(32,35): error TS2344: Type 'T[0][P]' does not satisfy the constraint 'any[]'.\r\n```"},"comment":{"url":"https://api.github.com/repos/crcn/sift.js/issues/comments/365902528","html_url":"https://github.com/crcn/sift.js/pull/135#issuecomment-365902528","issue_url":"https://api.github.com/repos/crcn/sift.js/issues/135","id":365902528,"user":{"login":"ryansmith94","id":3045513,"avatar_url":"https://avatars0.githubusercontent.com/u/3045513?v=4","gravatar_id":"","url":"https://api.github.com/users/ryansmith94","html_url":"https://github.com/ryansmith94","followers_url":"https://api.github.com/users/ryansmith94/followers","following_url":"https://api.github.com/users/ryansmith94/following{/other_user}","gists_url":"https://api.github.com/users/ryansmith94/gists{/gist_id}","starred_url":"https://api.github.com/users/ryansmith94/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryansmith94/subscriptions","organizations_url":"https://api.github.com/users/ryansmith94/orgs","repos_url":"https://api.github.com/users/ryansmith94/repos","events_url":"https://api.github.com/users/ryansmith94/events{/privacy}","received_events_url":"https://api.github.com/users/ryansmith94/received_events","type":"User","site_admin":false},"created_at":"2018-02-15T11:40:27Z","updated_at":"2018-02-15T11:40:27Z","author_association":"NONE","body":"For anyone else running into this issue, I suggest the following steps.\r\n\r\n1. Use the `typeRoots` compiler option with `[\"./@types\", \"./node_modules/@types\"]`.\r\n1. Use a `build` script in your package.json with `rm -f node_modules/sift/index.d.ts && tsc`.\r\n1. Create a `@types/sift/index.d.ts` file with the following contents.\r\n\r\n```ts\r\ndeclare module 'sift' {\r\n  export type SupportedTypes = Array<string | { [index: string]: any } | number | null | any>;\r\n  export type KeyOrValue<T extends SupportedTypes> = T & T[0];\r\n\r\n  export type ElemMatch<T extends { [index: string]: any[] }> = {\r\n    [P in keyof T]?: SiftQuery<T[P]>;\r\n  }\r\n\r\n  export type Query<T extends SupportedTypes> = {\r\n    $eq?: T[0];\r\n    $ne?: T[0];\r\n    $or?: Array<Partial<T[0]>>;\r\n    $gt?: T[0];\r\n    $gte?: T[0];\r\n    $lt?: T[0];\r\n    $lte?: T[0];\r\n    $mod?: number[];\r\n    $in?: Array<Partial<T[0]>>;\r\n    $nin?: Array<Partial<T[0]>>;\r\n    $not?: SiftQuery<T>;\r\n    $type?: any;\r\n    $all?: Array<Partial<T[0]>>;\r\n    $size?: number;\r\n    $nor?: Array<Partial<T[0]>>;\r\n    $and?: Array<Partial<T[0]>>;\r\n    $regex?: RegExp | string;\r\n    $elemMatch?: ExternalQuery<T>;\r\n    $exists?: boolean;\r\n    $where?: string | WhereFn<T>;\r\n    $options?: \"i\" | \"g\" | \"m\" | \"u\";\r\n  }\r\n\r\n  export interface InternalQuery<T extends SupportedTypes> extends Query<T> {\r\n  }\r\n\r\n  export type ExternalQuery<T extends SupportedTypes> = ElemMatch<T[0]>;\r\n\r\n  export type WhereFn<T extends SupportedTypes> = (this: T[0], value: T[0], index: number, array: T) => boolean;\r\n\r\n  export type FilterFn = <T>(value: T, index?: number, array?: T[]) => boolean;\r\n\r\n  export type SiftQuery<T extends SupportedTypes> = ExternalQuery<T> & InternalQuery<T>;\r\n\r\n  export type PluginDefinition<T> = {\r\n    [index: string]: (a: T, b: T) => boolean | number;\r\n  }\r\n\r\n  export type PluginFunction<T> = (sift: Sift) => PluginDefinition<T>;\r\n\r\n  export type Exec = <T extends SupportedTypes>(array: T) => T;\r\n\r\n  export interface Sift {\r\n    <T extends SupportedTypes>(query: RegExp, target: T, rawSelector?: any): T;\r\n    <T>(query: SiftQuery<any>, rawSelector: (item: T) => boolean): Exec;\r\n    <T extends SupportedTypes[]>(query: SiftQuery<T>): FilterFn;\r\n    <T extends SupportedTypes>(query: SiftQuery<T>, target: T, rawSelector?: any): T;\r\n    indexOf<T extends SupportedTypes>(query: SiftQuery<T>, target: T, rawSelector?: any): number;\r\n    use<K>(plugin: PluginFunction<K> | PluginDefinition<K>): void;\r\n    compare<T, K>(a: T, b: K): 0 | -1 | 1;\r\n  }\r\n\r\n  const x: Sift;\r\n  export default x;\r\n}\r\n```"}}
{"actor":{"display_login":"ryansmith94"}}