New definition for non npm package amap-js-api-map-type (#38759)

This commit is contained in:
breeze9527
2019-10-02 11:54:27 -07:00
committed by Ryan Cavanaugh
parent 21d1ea3691
commit bfab99e84d
4 changed files with 97 additions and 0 deletions
@@ -0,0 +1,32 @@
declare const map: AMap.Map;
// $ExpectType MapType
new AMap.MapType();
// $ExpectType MapType
new AMap.MapType({});
// $ExpectType MapType
const mapType = new AMap.MapType({
defaultType: 1,
showTraffic: true,
showRoad: true
});
// $ExpectError
new AMap.MapType({
defaultType: 2
});
// $ExpectType void
mapType.show();
// $ExpectType void
mapType.hide();
mapType.on('show', (event: AMap.MapType.EventMap['show']) => {
// $ExpectType "show"
event.type;
});
mapType.on('hide', (event: AMap.MapType.EventMap['hide']) => {
// $ExpectType "hide"
event.type;
});
+38
View File
@@ -0,0 +1,38 @@
// Type definitions for non-npm package amap-js-api-map-type 1.4
// Project: https://lbs.amap.com/api/javascript-api/reference/map-control#AMap.MapType
// Definitions by: breeze9527 <https://github.com/breeze9527>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
/// <reference types="amap-js-api" />
declare namespace AMap {
namespace MapType {
interface EventMap {
hide: Event<'hide'>;
show: Event<'show'>;
}
interface Options {
/**
* 初始化默认图层类型,默认为0
* 取值为0:默认底图
* 取值为1:卫星图
*/
defaultType?: 0 | 1;
/**
* 是否叠加实时交通图层,默认false
*/
showTraffic?: boolean;
/**
* 是否叠加路网图层,默认false
*/
showRoad?: boolean;
}
}
class MapType extends EventEmitter {
constructor(options?: MapType.Options);
show(): void;
hide(): void;
}
}
+24
View File
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noEmit": true,
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"amap-js-api-map-type-tests.ts"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}