본문 바로가기

dev/react-native

RN에서 TS사용시 styled-components/native type import 에러

1. 증상 및 환경

- window10

- styled-components 5.2.1

- @types/styled-components 5.1.7

 

2. 원인

native.d.ts 를 찾지 못해서 발생

 

3. 해결책

1) @types/styled-components를 설치했는지 확인한다.

 

2) 타입스크립트에서 noImplicitAny 옵션을 끈다. 초기에 styled components에 타입이슈가 많았을 때 쓴 방법이라고 한다. 그냥 에러로 잡지 않는 것이기 때문에 해결책이라 보기는 어렵다.

 

3) @types/styled-components 대신 @types/styled-components-react-native를 사용한다.

github.com/dooboolab/hackatalk/pull/331

 

Fix Styled Components Type Issue by 0916dhkim · Pull Request #331 · dooboolab/hackatalk

Specify project client Description styled-components package had type issue for over a year, and noImplicitAny option in tsconfig.json file was set to false as a temporary fix. The notorious type i...

github.com

@types/styled-components-react-native

'dev > react-native' 카테고리의 다른 글

vscode에서 expo react native 디버깅  (0) 2020.12.21
RN 초기 설정시 발생한 에러 처리  (0) 2020.11.20