add algolia places typings (#36242)

* add algolia places typings

* add request changes

* fix build errors

* fix test errors

* remove rules from tslint

* remove empty line

* add namespace places

* remove unused comma

* add missing whitespace and remove padding

* add test file

* add file to tsconfig

* comment places func

* add tests

* uncomment places func

* fix events import
This commit is contained in:
ghizlanelotfi
2019-06-21 14:19:32 -07:00
committed by Daniel Rosenwasser
parent 58607ca641
commit 4bc21cbc73
4 changed files with 102 additions and 0 deletions
+44
View File
@@ -0,0 +1,44 @@
// Type definitions for algolia places 1.16
// Project: https://github.com/algolia/places
// Definitions by: Ghizlane LOTFI <https://github.com/ghizlanelotfi>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
import { EventEmitter } from 'events';
declare namespace places {
function version(): string;
interface PlacesOptions {
appId: string;
apiKey: string;
container: string | HTMLInputElement | NodeList | Element;
}
interface AutompleteOptions {
autoselect: boolean;
hint: boolean;
cssClasses: {
root: string;
prefix: any;
};
debug: boolean;
}
interface Places {
rawAnswer: any;
query: any;
suggestion: any;
suggestionIndex: any;
}
interface Error {
message: string;
}
}
declare function places(
options: places.PlacesOptions
): EventEmitter;
export = places;
+31
View File
@@ -0,0 +1,31 @@
import * as places from "places";
import { EventEmitter } from "events";
const options: places.PlacesOptions = {
appId: 'your app Id',
apiKey: 'your api key',
container: '<input type=\"search\" id=\"address\">'
};
const autompleteOptions: places.AutompleteOptions = {
autoselect: true,
hint: true,
cssClasses: {
root: 'root',
prefix: 'prefix',
},
debug: true,
};
const placesObject: places.Places = {
rawAnswer: 'raw',
query: 'query',
suggestion: 'suggestion',
suggestionIndex: 'suggestionIndex'
};
const error: places.Error = {
message: 'message'
};
const algoliaplaces: EventEmitter = places(options);
+24
View File
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es2016",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"places-tests.ts"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}