我在编译打字稿代码时遇到错误。
错误:
类型的参数'{method:string; headers:{'Accept':string; 'Content-Type':字符串; '授权':字符串; } ...'不能赋值给'RequestInit'类型的参数。 属性“标题”的类型不兼容。 输入'{'Accept':string; 'Content-Type':字符串; '授权':字符串; }'不能赋值为'Headers |串[][]'。 对象文字只能指定已知属性,而''接头''在类型'标题|中不存在串[][]'。 终端进程以退出代码终止:1
fetch(URL, {
method: 'GET',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': "Bearer " + token
}
})
.then((responseJson) => {
return responseJson;
})
.catch((error) => {
console.error(error);
});
"dependencies": {
"expo": "^21.0.2",
"jquery": "^3.2.1",
"lodash": "^4.17.4",
"mobx": "^3.2.2",
"mobx-react": "^4.2.2",
"moment": "^2.19.1",
"react": "16.0.0-alpha.12",
"react-native": "https://github.com/expo/react-native/archive/sdk-21.0.2.tar.gz",
"react-native-azure-ad": "^0.2.4",
"react-native-sqlite-2": "^1.5.0",
"react-native-sqlite-storage": "^3.3.3",
"react-native-tabs": "^1.0.9",
"typescript": "^2.5.3"
}