Skip to content

Commit 4f58e73

Browse files
committed
fix(maps): 补全 BMap/TMap SDK 类型声明,修复 dts 生成失败
#2878 迁移 bmap/tmap 到 BaseMap 后 SDK 类型缺 on/off/getMinZoom/getMaxZoom/getContainer/panBy 等成员声明, father declaration 生成失败, 阻塞 fixed group 发布。 新增 ambient map-sdk-augmentation.d.ts 用 namespace 接口合并 补齐; bmap 补 version 声明; handleCameraChanged 改可选调用 cameraChangedCallback?.。 全量 pnpm build 通过, 无运行时行为变更。 详 .changeset/fix-maps-bmap-tmap-types.md
1 parent 628ed21 commit 4f58e73

4 files changed

Lines changed: 65 additions & 2 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
'@antv/l7-maps': patch
3+
---
4+
5+
fix(maps): 补全 BMap/TMap SDK 类型声明,修复 father dts 生成失败
6+
7+
PR #2878 将 bmap/tmap 迁移到 BaseMap 后,maps 包全量 build 在
8+
father 的 declaration 生成阶段中断 (exit 1),阻塞 fixed group
9+
整体发布。根因是第三方 SDK 类型缺失运行时存在、但 .d.ts 未声明的
10+
成员:
11+
12+
- @types/bmapgl 的 BMapGL.Map 未声明 on/off/getMinZoom/getMaxZoom
13+
(bmap/map.ts 直接 this.map.on(...)/getMinZoom() 调用报 TS2339/2551)
14+
- @map-component/tmap-types 的 TMap.Map 未声明 getContainer/panBy
15+
(tmap/map.ts 7 处 getContainer + panBy 报 TS2339,连带
16+
addEventListener 回调 e 隐式 any)
17+
18+
修法 (补类型声明,非 as any 投机转换):
19+
20+
- 新增 packages/maps/map-sdk-augmentation.d.ts (ambient,与现有
21+
style.d.ts 同级,tsconfig 默认 include 覆盖):
22+
通过 namespace 接口合并为 BMapGL.Map 补 on/off/getMinZoom/
23+
getMaxZoom,为 TMap.Map 补 getContainer()/panBy([x,y])。
24+
无运行时代码,仅声明增强。
25+
- bmap/map.ts: 补 public version: string = BMAP_VERSION 声明
26+
(对齐 maplibre/map.ts、map/map.ts 惯例;此前只赋值未声明)
27+
- bmap/tmap map.ts: handleCameraChanged 中
28+
this.cameraChangedCallback(...) 改 ?. 可选调用,与 BaseMap
29+
updateView 一致 (cameraChangedCallback 为可选属性)
30+
31+
验证: pnpm --filter @antv/l7-maps build 0 error (48 files),
32+
pnpm 全量 build 通过 (fixed group 解除阻塞),eslint 0 error。
33+
无运行时行为变更。
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* 第三方地图 SDK 类型补全
3+
*
4+
* @types/bmapgl 与 @map-component/tmap-types 未声明、但运行时确实存在且
5+
* L7 maps 服务依赖的 BMapGL.Map / TMap.Map 成员。通过 interface 合并增强,
6+
* 不引入任何运行时代码。
7+
*
8+
* 详见: packages/maps/src/{bmap,tmap}/map.ts
9+
*/
10+
declare namespace BMapGL {
11+
interface Map {
12+
// BMapGL.Map 继承 EventEmitter,但 @types/bmapgl 未声明 on/off
13+
on(type: string, handler: (...args: any[]) => void): void;
14+
off(type: string, handler: (...args: any[]) => void): void;
15+
// 与 setMinZoom/setMaxZoom 对应的 getter,运行时存在
16+
getMinZoom(): number;
17+
getMaxZoom(): number;
18+
}
19+
}
20+
21+
declare namespace TMap {
22+
interface Map {
23+
// 返回地图容器 DOM,@map-component/tmap-types 未声明
24+
getContainer(): HTMLElement;
25+
// 按像素偏移平移地图,运行时接受 [x, y] 元组
26+
panBy(offset: [number, number]): void;
27+
}
28+
}

packages/maps/src/bmap/map.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ export default class BMapService extends BaseMap<BMapGL.Map> {
3737
};
3838
protected currentStyle: any = 'normal';
3939

40+
public version: string = BMAP_VERSION;
41+
4042
// Zoom 偏移量,用于对齐不同地图的显示层级
4143
protected zoomOffset: number = 1.75;
4244

@@ -76,7 +78,7 @@ export default class BMapService extends BaseMap<BMapGL.Map> {
7678
if (this.viewport) {
7779
this.viewport.syncWithMapCamera(option as any);
7880
this.updateCoordinateSystemService();
79-
this.cameraChangedCallback(this.viewport);
81+
this.cameraChangedCallback?.(this.viewport);
8082
}
8183
};
8284

packages/maps/src/tmap/map.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export default class TMapService extends BaseMap<TMap.Map> {
6262
if (this.viewport) {
6363
this.viewport.syncWithMapCamera(option as any);
6464
this.updateCoordinateSystemService();
65-
this.cameraChangedCallback(this.viewport);
65+
this.cameraChangedCallback?.(this.viewport);
6666
}
6767
};
6868

0 commit comments

Comments
 (0)