DefinitelyTyped/types/amap-js-api-arrival-range/amap-js-api-arrival-range-tests.ts
breeze9527 bdd066eeb8 Add type definition of non npm package amap-js-api-arrival-range (#35290)
* [amap-js-api] update to v1.4.14

* Add definition for non npm package: amap-js-api-district-search

* Add type definition for non npm-package amap-js-api-line-search

* Add type definition of non npm package amap-js-api-arrival-range
2019-05-13 10:37:33 -07:00

43 lines
1.1 KiB
TypeScript

declare const lnglat: AMap.LngLat;
declare const lnglatTuple: [number, number];
// $ExpectType ArrivalRange
const arrivalRange = new AMap.ArrivalRange();
// $ExpectType void
arrivalRange.search(lnglat, 10, (status, result) => {
const tempStatus: 'complete' | 'error' | 'no_data' = status;
if (typeof result !== 'string') {
// $ExpectType SearchResult
result;
// $ExpectType string
result.bounds[0][0][0][0];
// $ExpectType boolean[] | undefined
result.inRange;
// $ExpectType string
result.info;
// $ExpectType string
result.infocode;
} else {
// $ExpectType string
result;
}
});
// $ExpectType void
arrivalRange.search(lnglatTuple, 10, () => { });
// $ExpectType void
arrivalRange.search(lnglatTuple, 10, () => { }, {});
// $ExpectType void
arrivalRange.search(lnglat, 10, () => { }, {
policy: 'BUS',
resultType: 'polygon',
destination: lnglat
});
arrivalRange.on('error', (event: AMap.ArrivalRange.EventMap['error']) => {
// $ExpectType string
event.info;
// $ExpectType "error"
event.type;
});