deitch/searchjs

Adding type definitions for project

Opened this issue · 5 comments

Trying to use this project in a typescript project will fail because it doesn't have type definitions.

PRs definitely welcome.

Added a PR to DefinitelyTyped

DefinitelyTyped/DefinitelyTyped#43370

Awesome thanks!

@iammerus Hey so would it be possible to add types for the searchjs filters?

Here is what I came up:

interface FilterRange {
  from?: number
  to?: number
  gt?: number
  lt?: number
  gte?: number
  lte?: number
}

interface Primative {
  [key: string]: string | number | Date | string[] | number[] | boolean | FilterRange | undefined
}

interface Modifier {
  _propertySearch?: boolean
  _propertySearchDepth?: number
  _join?: "OR" | "AND"
  _not?: boolean
  _text?: boolean
  _word?: boolean
  _start?: boolean
  _end?: boolean
  _regexp?: boolean
  _separator?: string
  terms?: Filter[]
}

type Filter = Primative | Modifier

Let me know if you want me to add these