Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .changeset/fix-maps-bmap-tmap-types.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
'@antv/l7-maps': patch
---

fix(maps): 补全 BMap/TMap SDK 类型声明,修复 father dts 生成失败

PR #2878 将 bmap/tmap 迁移到 BaseMap 后,maps 包全量 build 在
father 的 declaration 生成阶段中断 (exit 1),阻塞 fixed group
整体发布。根因是第三方 SDK 类型缺失运行时存在、但 .d.ts 未声明的
成员:

- @types/bmapgl 的 BMapGL.Map 未声明 on/off/getMinZoom/getMaxZoom
(bmap/map.ts 直接 this.map.on(...)/getMinZoom() 调用报 TS2339/2551)
- @map-component/tmap-types 的 TMap.Map 未声明 getContainer/panBy
(tmap/map.ts 7 处 getContainer + panBy 报 TS2339,连带
addEventListener 回调 e 隐式 any)

修法 (补类型声明,非 as any 投机转换):

- 新增 packages/maps/map-sdk-augmentation.d.ts (ambient,与现有
style.d.ts 同级,tsconfig 默认 include 覆盖):
通过 namespace 接口合并为 BMapGL.Map 补 on/off/getMinZoom/
getMaxZoom,为 TMap.Map 补 getContainer()/panBy([x,y])。
无运行时代码,仅声明增强。
- bmap/map.ts: 补 public version: string = BMAP_VERSION 声明
(对齐 maplibre/map.ts、map/map.ts 惯例;此前只赋值未声明)
- bmap/tmap map.ts: handleCameraChanged 中
this.cameraChangedCallback(...) 改 ?. 可选调用,与 BaseMap
updateView 一致 (cameraChangedCallback 为可选属性)

验证: pnpm --filter @antv/l7-maps build 0 error (48 files),
pnpm 全量 build 通过 (fixed group 解除阻塞),eslint 0 error。
无运行时行为变更。
28 changes: 28 additions & 0 deletions packages/maps/map-sdk-augmentation.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* 第三方地图 SDK 类型补全
*
* @types/bmapgl 与 @map-component/tmap-types 未声明、但运行时确实存在且
* L7 maps 服务依赖的 BMapGL.Map / TMap.Map 成员。通过 interface 合并增强,
* 不引入任何运行时代码。
*
* 详见: packages/maps/src/{bmap,tmap}/map.ts
*/
declare namespace BMapGL {
interface Map {
// BMapGL.Map 继承 EventEmitter,但 @types/bmapgl 未声明 on/off
on(type: string, handler: (...args: any[]) => void): void;
off(type: string, handler: (...args: any[]) => void): void;
// 与 setMinZoom/setMaxZoom 对应的 getter,运行时存在
getMinZoom(): number;
getMaxZoom(): number;
}
}

declare namespace TMap {
interface Map {
// 返回地图容器 DOM,@map-component/tmap-types 未声明
getContainer(): HTMLElement;
// 按像素偏移平移地图,运行时接受 [x, y] 元组
panBy(offset: [number, number]): void;
}
}
4 changes: 3 additions & 1 deletion packages/maps/src/bmap/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ export default class BMapService extends BaseMap<BMapGL.Map> {
};
protected currentStyle: any = 'normal';

public version: string = BMAP_VERSION;

// Zoom 偏移量,用于对齐不同地图的显示层级
protected zoomOffset: number = 1.75;

Expand Down Expand Up @@ -76,7 +78,7 @@ export default class BMapService extends BaseMap<BMapGL.Map> {
if (this.viewport) {
this.viewport.syncWithMapCamera(option as any);
this.updateCoordinateSystemService();
this.cameraChangedCallback(this.viewport);
this.cameraChangedCallback?.(this.viewport);
}
};

Expand Down
2 changes: 1 addition & 1 deletion packages/maps/src/tmap/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export default class TMapService extends BaseMap<TMap.Map> {
if (this.viewport) {
this.viewport.syncWithMapCamera(option as any);
this.updateCoordinateSystemService();
this.cameraChangedCallback(this.viewport);
this.cameraChangedCallback?.(this.viewport);
}
};

Expand Down
Loading