Skip to content

Commit

Permalink
refactor: 调整类型声明的方式
Browse files Browse the repository at this point in the history
  • Loading branch information
xyy94813 committed Oct 28, 2023
1 parent 3771438 commit 923ff5e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
4 changes: 3 additions & 1 deletion src/@types/AMap.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable import/no-extraneous-dependencies */
/* eslint-disable max-classes-per-file */
import { _PolylineEditor } from '@amap/amap-jsapi-types/plugins/PolylineEditor';
import '@amap/amap-jsapi-types';

// 对 amap type 做扩展
declare global {
namespace AMap {
Expand Down Expand Up @@ -114,6 +114,8 @@ declare global {

remove: () => void;
}

export class PolylineEditor2 extends _PolylineEditor {}
}

namespace AMapUI {
Expand Down
6 changes: 1 addition & 5 deletions src/components/AMapPolygonEditor/AMapPolygonEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ import {
useEffect,
useRef,
} from 'react';
// eslint-disable-next-line import/no-extraneous-dependencies
import {
_PolygonEditor as PolygonEditor,
} from '@amap/amap-jsapi-types/plugins/PolygonEditor';

import useAMap from '../../hooks/useAMap';
import useAMapPluginInstance from '../../hooks/useAMapPluginInstance';
Expand All @@ -26,7 +22,7 @@ const AMapPolygonEditor: FC<AMapPolygonEditorProps> = ({
$lastOnChange.current = onChange;

const initInstance = useCallback((AMap, map) => new AMap!.PolygonEditor(map), []);
const curInstance = useAMapPluginInstance<PolygonEditor>('PolygonEditor', initInstance);
const curInstance = useAMapPluginInstance<AMap.PolygonEditor>('PolygonEditor', initInstance);
const { map } = useAMap();

const reSetTarget = useCallback(() => {
Expand Down
7 changes: 1 addition & 6 deletions src/components/AMapPolylineEditor/AMapPolylineEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ import {
useRef,
} from 'react';

// eslint-disable-next-line import/no-extraneous-dependencies
import {
_PolylineEditor as PolylineEditor,
} from '@amap/amap-jsapi-types/plugins/PolylineEditor';

import useAMap from '../../hooks/useAMap';
import useAMapPluginInstance from '../../hooks/useAMapPluginInstance';
import { isPolyline } from '../../helpers/amapHelper';
Expand All @@ -26,7 +21,7 @@ const AMapPolylineEditor: FC<AMapPolylineEditorProps> = ({
$lastOnChange.current = onChange;

const initInstance = useCallback((AMap, map) => new AMap!.PolylineEditor(map), []);
const curInstance = useAMapPluginInstance<PolylineEditor>('PolylineEditor', initInstance);
const curInstance = useAMapPluginInstance<AMap.PolylineEditor2>('PolylineEditor', initInstance);
const { map } = useAMap();

const reSetTarget = useCallback(() => {
Expand Down

0 comments on commit 923ff5e

Please sign in to comment.