From 43a6d3c3c92d5a4e1ffe4ec805106ba400fc58da Mon Sep 17 00:00:00 2001 From: Haroen Viaene Date: Tue, 6 Aug 2019 17:52:38 +0200 Subject: [PATCH] [algoliasearch] change module format (#37284) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [algoliasearch] change module format TBH I'm not really sure what the difference is, but this doesn't break any tests on my repositories. It was needed to work with `/// reference` imports (cc @samuelbodin) I also had to remove the Omit type for some reason to rely on the builtin one, I guess that's not too big of a deal? * update algoliasearch-helper too * more updates 🙈 * modern module format & revert TS version changes * Update types/react-instantsearch/index.d.ts --- types/algoliasearch/algoliasearch-tests.ts | 44 +++++++++++++--------- types/algoliasearch/index.d.ts | 1 + types/algoliasearch/lite/index.d.ts | 2 +- 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/types/algoliasearch/algoliasearch-tests.ts b/types/algoliasearch/algoliasearch-tests.ts index 848a0586c9..a71779378a 100644 --- a/types/algoliasearch/algoliasearch-tests.ts +++ b/types/algoliasearch/algoliasearch-tests.ts @@ -9,8 +9,9 @@ import { Response, IndexSettings, QueryParameters, - Client + Client, } from 'algoliasearch'; +import * as algoliasearchLite from 'algoliasearch/lite'; let _algoliaResponse: Response = { hits: [{}, {}], @@ -141,14 +142,14 @@ let _algoliaQueryParameters: QueryParameters = { removeStopWords: [''], disableExactOnAttributes: [''], exactOnSingleWordQuery: 'attribute', - alternativesAsExact: ["ignorePlurals"], + alternativesAsExact: ['ignorePlurals'], distinct: 0, getRankingInfo: false, numericAttributesToIndex: [''], numericAttributesForFiltering: [''], numericFilters: [''], tagFilters: [''], - facetFilters: ['',['']], + facetFilters: ['', ['']], analytics: false, clickAnalytics: true, analyticsTags: [''], @@ -177,14 +178,14 @@ index.partialUpdateObjects([{}], false, () => {}); index.partialUpdateObjects([{}]).then(() => {}); index.partialUpdateObjects([{}], false).then(() => {}); -let indexName : string = index.indexName; +let indexName: string = index.indexName; // complete copy -client.copyIndex('from', 'to').then(()=>{}); -client.copyIndex('from', 'to', ()=> {}); +client.copyIndex('from', 'to').then(() => {}); +client.copyIndex('from', 'to', () => {}); // with scope -client.copyIndex('from', 'to', ['settings']).then(()=>{}); -client.copyIndex('from', 'to', ['synonyms', 'rules'], ()=> {}); +client.copyIndex('from', 'to', ['settings']).then(() => {}); +client.copyIndex('from', 'to', ['synonyms', 'rules'], () => {}); // Browsing const browser = index.browseAll(); @@ -200,7 +201,7 @@ browser.on('result', function onResult(content) { }); browser.on('end', function onEnd() { - const _message = `We got ${hits.length} hits` + const _message = `We got ${hits.length} hits`; }); browser.on('error', function onError(err) { @@ -209,14 +210,23 @@ browser.on('error', function onError(err) { browser.stop(); -index.setSettings({ hitsPerPage: 10 }, () => {}) -index.setSettings({ hitsPerPage: 10 }, { forwardToReplicas: true }, () => {}) -index.setSettings({ hitsPerPage: 10 }).then(() => {}) -index.setSettings({ hitsPerPage: 10 }, { forwardToReplicas: true }).then(() => {}) +index.setSettings({ hitsPerPage: 10 }, () => {}); +index.setSettings({ hitsPerPage: 10 }, { forwardToReplicas: true }, () => {}); +index.setSettings({ hitsPerPage: 10 }).then(() => {}); +index + .setSettings({ hitsPerPage: 10 }, { forwardToReplicas: true }) + .then(() => {}); -index.browse("", { +index.browse('', { advancedSyntax: false, - attributesToRetrieve: ['dogs'] + attributesToRetrieve: ['dogs'], }); -client.copyIndex('from', 'to', ['settings']).then(()=>{}); -client.copyIndex('from', 'to', ['synonyms', 'rules'], ()=> {}); +client.copyIndex('from', 'to', ['settings']).then(() => {}); +client.copyIndex('from', 'to', ['synonyms', 'rules'], () => {}); + +const liteClient: algoliasearchLite.Client = algoliasearchLite('', ''); + +liteClient.search([], (err: Error, res: algoliasearch.MultiResponse) => {}); +liteClient.search([]).then((res: algoliasearch.MultiResponse) => {}); +type Res = { zipzop: true }; +liteClient.search([]).then((res: algoliasearch.MultiResponse) => {}); diff --git a/types/algoliasearch/index.d.ts b/types/algoliasearch/index.d.ts index 1081fda7c9..76b14c019d 100644 --- a/types/algoliasearch/index.d.ts +++ b/types/algoliasearch/index.d.ts @@ -2100,3 +2100,4 @@ interface AlgoliaStatic extends AlgoliasearchInstance { declare const algoliasearch: AlgoliaStatic; export = algoliasearch; +export as namespace algoliasearch; diff --git a/types/algoliasearch/lite/index.d.ts b/types/algoliasearch/lite/index.d.ts index 53692b7b37..f0369cb47b 100644 --- a/types/algoliasearch/lite/index.d.ts +++ b/types/algoliasearch/lite/index.d.ts @@ -18,7 +18,7 @@ import { Response, BrowseParameters, BrowseResponse -} from '../index'; +} from 'algoliasearch'; declare namespace algoliasearch { /**