반응 모듈과 반응 고유 모듈을 가져 왔으며 그 모듈에 대한 유형 정의가 설치되어 있습니다 (typings 통해).Typescript React Native 프로젝트에서 가져 오기 기능에 대한 유형 정의를 얻으려면 어떻게해야합니까?
가져 오기 기능이 인식되지 않습니다. 어떻게 작동시킬 수 있습니까?
src/reducers/calendar/actions.ts(16,5): error TS2304: Cannot find name 'fetch'.
반응 모듈과 반응 고유 모듈을 가져 왔으며 그 모듈에 대한 유형 정의가 설치되어 있습니다 (typings 통해).Typescript React Native 프로젝트에서 가져 오기 기능에 대한 유형 정의를 얻으려면 어떻게해야합니까?
가져 오기 기능이 인식되지 않습니다. 어떻게 작동시킬 수 있습니까?
src/reducers/calendar/actions.ts(16,5): error TS2304: Cannot find name 'fetch'.
현재 타이프 라이터가 typings.json
사용되지 않는 때문에이 솔루션은 작동하지 않습니다 업데이트되었습니다.
2016년 10월 28일 업데이트되었습니다. 이 라인을 typings/globals/react-native/index.d.ts
에 추가했습니다.
원래
5643: export type fetch = (url: string, options?: Object) => Promise<any>
5644: export const fetch: fetch; // patch `fetch` not found problem
action.ts
)에 다음 행을 추가했다.import {fetch} from "react-native";
내 typings.json
:
{
"globalDependencies": {
"fbemitter": "registry:dt/fbemitter#2.0.0+20160618175531",
"flux": "registry:dt/flux#0.0.0+20160618175531",
"immutable": "registry:dt/immutable#3.8.1+20160608070634",
"react": "registry:dt/react#0.14.0+20160927082313",
"react-dom": "registry:dt/react-dom#0.14.0+20160412154040",
"react-native": "registry:dt/react-native#0.29.0+20160928135220",
"react-native-button": "file:typings/custom/react-native-button/index.d.ts",
"react-native-fbsdk": "file:typings/custom/react-native-fbsdk/index.d.ts"
},
"dependencies": {
"react-native-router-flux": "npm:react-native-router-flux",
"rxjs": "npm:rxjs"
}
}
내 package.json
: 타이프의
{
"name": "SomeApp",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start"
},
"dependencies": {
"flux": "^3.1.0",
"react": "15.3.2",
"react-native": "0.34.1",
"react-native-button": "^1.7.1",
"react-native-fbsdk": "^0.3.0",
"react-native-linkedin-login": "^1.3.0",
"react-native-localization": "^0.1.22",
"react-native-router-flux": "^3.35.0",
"react-native-scrollable-tab-view": "^0.6.0",
"rxjs": "^5.0.0-rc.1",
"typings": "1.4.0"
},
"devDependencies": {
"typescript": "2.0.3"
}
}
나를 위해 작동하지 않습니다. 'src/reducers/calendar/actions.ts (18,5) : error TS2304 : 'fetch'라는 이름을 찾을 수 없습니다.'typings.json에서이 유형 정의 파일을 사용하고 있습니다 :''react-native ': "registry : dt/react-native # 0.29.0 + 20160830141535" ' – cubabit
이 유형 정의를 사용하고 있습니다 : "react-native": "registry : dt/react-native # 0.29.0 + 20160928135220". 내 것 같다. 변경된 사항을 확인하겠습니다. – HKTonyLee
@cubabit 안녕하세요, 저는 react-native.d.ts의 관리자입니다. 'fetch'는'export type fetch = (url : string, options ?: Object) => Promise
이 나타나는 최신 버전에 내장 된 가져 오기 정의를 가지고,하지만 난 형의 정의가 같은 Axios의 같은 발견 라이브러리가 내장 제네릭 포함하여 사용하기 좋네 – cubabit