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 1e4c31e commit 3771438
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/components/AMapPolygonEditor/AMapPolygonEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ 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 @@ -22,7 +26,7 @@ const AMapPolygonEditor: FC<AMapPolygonEditorProps> = ({
$lastOnChange.current = onChange;

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

const reSetTarget = useCallback(() => {
Expand Down
7 changes: 6 additions & 1 deletion src/components/AMapPolylineEditor/AMapPolylineEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ 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 @@ -21,7 +26,7 @@ const AMapPolylineEditor: FC<AMapPolylineEditorProps> = ({
$lastOnChange.current = onChange;

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

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

0 comments on commit 3771438

Please sign in to comment.