diff --git a/types/frecency/index.d.ts b/types/frecency/index.d.ts new file mode 100644 index 0000000000..e1081d94c7 --- /dev/null +++ b/types/frecency/index.d.ts @@ -0,0 +1,28 @@ +// Type definitions for frecency 1.3 +// Project: https://github.com/mixmaxhq/frecency#readme +// Definitions by: swyx +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +// TypeScript Version: 2.3 + +export type idAttrFn = (result: string) => string; +export default class Frecency { + constructor(constructOpts: { + key: string; + idAttribute?: string | idAttrFn; + timeStampsLimit?: number; + recentSelectionsLimit?: number; + storageProvider?: object; + exactQueryMatchWeight?: number; + subQueryMatchWeight?: number; + recentSelectionsMatchWeight?: number; + }); + save: (arg: { searchQuery: T; selectedId: string }) => void; + sort: + | ((arg: { searchQuery: T; searchResults: T[] }) => T[]) + | ((arg: { + searchQuery: T; + searchResults: T[]; + keepScores?: boolean; + }) => Array); +} diff --git a/types/frecency/tsconfig.json b/types/frecency/tsconfig.json new file mode 100644 index 0000000000..f21746e653 --- /dev/null +++ b/types/frecency/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": ["index.d.ts"] +} diff --git a/types/frecency/tslint.json b/types/frecency/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/frecency/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }