인프런 커뮤니티 질문&답변

매력적인홍홍홍님의 프로필 이미지

작성한 질문수

맛집 지도앱 만들기 (React Native + NestJS)

[5-3] 장소 등록하기(4) - 주소 조회 with Google API

marker.d.ts 관련

해결된 질문

24.05.01 15:45 작성

·

159

·

수정됨

1

강의에 나오는것처럼 진행했을때

import {LatLng, MapMarkerProps} from 'react-native-maps';

declare module 'react-native-maps' {
  export interface MyMapMarkerProps extends MapMarkerProps {
    coordinate?: LatLng;
  }
}


'MyMapMarkerProps' 인터페이스가 'MapMarkerProps' 인터페이스를 잘못 확장합니다.
'MyMapMarkerProps' 형식은 '{ anchor?: Point | undefined; calloutAnchor?: Point | undefined; calloutOffset?: Point | undefined; centerOffset?: Point | undefined; coordinate: LatLng; ... 22 more ...; zIndex?: number | undefined; }' 형식에 할당할 수 없습니다.
'coordinate' 속성의 형식이 호환되지 않습니다.
'LatLng | undefined' 형식은 'LatLng' 형식에 할당할 수 없습니다.
'undefined' 형식은 'LatLng' 형식에 할당할 수 없습니다.ts(2430)

Error (TS2430) |

 

MyMapMarkerProps 인터페이스가 MapMarkerProps 인터페이스를 잘못 확장합니다.

 

  

MyMapMarkerProps 형식은 { anchor?: Point | undefined; calloutAnchor?: Point | undefined; calloutOffset?: Point | undefined; centerOffset?: Point | undefined; coordinate: LatLng; ... 22 more ...; zIndex?: number | undefined; } 형식에 할당할 수 없습니다.

동일하게 ?을 넣을 수없는 에러가 생겨서

 

import {LatLng, MapMarkerProps} from 'react-native-maps';

declare module 'react-native-maps' {
  export interface MyMapMarkerProps extends Partial<MapMarkerProps> {
    coordinate?: LatLng;
  }
}

우선 아래와 같이 처리해 보았습니다만

CustomMarker.tsx에서 MyMapMarkerProps를 못불러오는 문제가 있습니다.

답변 2

0

김용민님의 프로필 이미지

2024. 05. 05. 03:48

저도 위와 동일한 에러가 발생했는데 어떻게 해결하셨을까요?

0

매력적인홍홍홍님의 프로필 이미지

2024. 05. 01. 16:03

현재는 extends MapMarkerProps를 뺀 형태로 우선 넘어갔습니다.

interface CustomMarkerProps {
  coordinate?: LatLng;
  color: MarkerColor;
  score?: number;
}