TypeScript를 사용하여 ReactNative 구성 요소에 MomentJS을 사용하고 싶습니다. 내 프로젝트는 노드 모듈 디렉토리에서 library's d.ts file을 가져 오도록 구성되었습니다.TypeScript React 네이티브 프로젝트에서 왜 moment를 임포트로 사용할 수 없습니까?
import * as moment from "moment";
const time = moment();
내 타이프 라이터 컴파일하지만 난 그렇게으로 응용 프로그램 ReactNative 오류를 실행할 때 :
이 내 입니다
이 내가 라이브러리를 가져오고 그것을 사용하고 어떻게 tsconfig.json 파일 :
{
"compilerOptions": {
"target": "es6",
"moduleResolution": "node",
"jsx": "react",
"outDir": "build/",
"sourceMap": true,
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true
}
}
tsconfig 'target'을 es5로 변경하면 다른 많은 모듈에 문제가 있습니다.
나는 this question과 관련이 있다고 생각하지만 그 질문의 답에 제안대로하고 있습니다.
가져온 항목 호출에 대한 의견은 http://stackoverflow.com/questions/39415661/why-cant-i-import-a-class-or-function-with-import-as-x-from-y를 참조하십시오. '*'를 사용하여 –