• 카테고리

    질문 & 답변
  • 세부 분야

    모바일 앱 개발

  • 해결 여부

    해결됨

marker.d.ts 에러 문제

24.05.05 03:49 작성 조회수 50

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님의 프로필

Kyo

지식공유자

2024.05.05

Omit을 이용해서 coordinate를 제외한 뒤에 추가해보시겠어요?

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

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


그리고 코드를 올리실때는 이렇게 코드블럭이나 깃헙을 활용해주세요!

김용민님의 프로필

김용민

질문자

2024.05.13

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