인프런 커뮤니티 질문&답변
marker.d.ts 에러 문제
해결된 질문
작성
·
236
1
import {LatLng, MapMarkerProps} from 'react-native-maps';
// marker props의 타입을 변경
declare module 'react-native-maps' {
export interface MyMapMarkerProps extends MapMarkerProps {
coordinate?: LatLng;
}
}
Interface 'MyMapMarkerProps' incorrectly extends interface 'MapMarkerProps'.
Type 'MyMapMarkerProps' is not assignable to type '{ anchor?: Point | undefined; calloutAnchor?: Point | undefined; calloutOffset?: Point | undefined; centerOffset?: Point | undefined; coordinate: LatLng; ... 22 more ...; zIndex?: number | undefined; }'.
Types of property 'coordinate' are incompatible.
Type 'LatLng | undefined' is not assignable to type 'LatLng'.
Type 'undefined' is not assignable to type 'LatLng'.ts(2430)
이런 에러가 발생합니다. 강의와 동일하게 했는데 그렇습니다! 아래 질문주신분 답변에 응답이 없어서 다시 질문드리는 점 양해부탁드립니다!
답변 1
0
Kyo
지식공유자
Omit을 이용해서 coordinate를 제외한 뒤에 추가해보시겠어요?
import {LatLng, MapMarkerProps} from 'react-native-maps';
declare module 'react-native-maps' {
export interface MyMapMarkerProps extends Omit<MapMarkerProps, 'coordinate'> {
coordinate?: LatLng;
}
}
그리고 코드를 올리실때는 이렇게 코드블럭이나 깃헙을 활용해주세요!





코드블럭을 활용해서 올리는데 이게 인프런 문제인지, 계속 게시를 하면 저렇게 변환이 되네요 ㅠ 죄송합니다