[amap-js-api] Update constructor of AMap.Bounds

This commit is contained in:
breeze9527 2019-04-11 20:41:01 +08:00
parent 55ece09ae5
commit c7c036dc21
3 changed files with 32 additions and 10 deletions

View File

@ -60,6 +60,16 @@ testArrayBounds.getCenter();
// $ExpectType Bounds
const testBounds = new AMap.Bounds(lnglat, lnglat);
// $ExpectType Bounds
new AMap.Bounds();
// $ExpectError
new AMap.Bounds([0, 0, 0]);
// $ExpectType Bounds
new AMap.Bounds([0, 0, 0, 0]);
// $ExpectType Bounds
new AMap.Bounds(lnglatTuple, lnglatTuple);
// $ExpectType Bounds
new AMap.Bounds(0, 0, 0, 0);
// $ExpectType boolean
testBounds.contains(lnglat);

View File

@ -1,11 +1,24 @@
declare namespace AMap {
class Bounds {
/**
*
* @param coords 西[西 西]
*/
constructor(coords?: [number, number, number, number]);
/**
*
* @param southWest 西
* @param northEast
*/
constructor(southWest: LngLat, northEast: LngLat);
constructor(southWest: LocationValue, northEast: LocationValue);
/**
*
* @param southWestLng 西
* @param southWestLat 西
* @param northEastLng
* @param northEastLat
*/
constructor(southWestLng: number, southWestLat: number, northEastLng: number, northEastLat: number);
/**
*
* @param point

View File

@ -8,10 +8,9 @@ declare namespace AMap {
* @param once
* @param unshift
*/
on<E extends Event, C = this>(
on<C = this>(
eventName: string,
// tslint:disable-next-line:no-unnecessary-generics
handler: (this: C, event: E) => void,
handler: (this: C, event: any) => void,
context?: C,
once?: boolean,
unshift?: boolean
@ -22,10 +21,10 @@ declare namespace AMap {
* @param handler
* @param context
*/
off<E extends Event, C = this>(
off<C = this>(
eventName: string,
// tslint:disable-next-line
handler: ((this: C, event: E) => void) | 'mv',
handler: ((this: C, event: any) => void) | 'mv',
context?: C
): this;
/**
@ -61,12 +60,12 @@ declare namespace AMap {
* @param handler
* @param context
*/
function addListener<I extends EventEmitter, E extends Event, C = I>(
function addListener<I extends EventEmitter, C = I>(
// tslint:disable-next-line: no-unnecessary-generics
instance: I,
eventName: string,
// tslint:disable-next-line: no-unnecessary-generics
handler: (this: C, event: E) => void,
handler: (this: C, event: any) => void,
// tslint:disable-next-line: no-unnecessary-generics
context?: C
): EventListener<1>;
@ -77,12 +76,12 @@ declare namespace AMap {
* @param handler
* @param context
*/
function addListenerOnce<I extends EventEmitter, E extends Event, C = I>(
function addListenerOnce<I extends EventEmitter, C = I>(
// tslint:disable-next-line: no-unnecessary-generics
instance: I,
eventName: string,
// tslint:disable-next-line: no-unnecessary-generics
handler: (this: C, event: E) => void,
handler: (this: C, event: any) => void,
// tslint:disable-next-line: no-unnecessary-generics
context?: C
): EventListener<1>;