我试图将基于expo的react native应用重写为TypeScript,而AppLoading组件会产生一些我不知道如何处理TypeScript样式的错误。
代码:
if (!this.state.isLoadingComplete && !this.props.skipLoadingScreen) {
return (
<AppLoading
startAsync={this.loadResourcesAsync}
onError={this.handleLoadingError}
onFinish={this.handleFinishLoading}
/>
);
} else {
return (
<View style={Styles.container}>
{Platform.OS === 'ios' && <StatusBar barStyle="default" />}
<AppNavigator />
</View>
);
}
public loadResourcesAsync = async (): Promise<any> => {
return Promise.all([
Asset.loadAsync([
require('./assets/images/bankid.png'),
]),
Font.loadAsync({
// This is the font that we are using for our tab bar
...Icon.Feather.font,
// We include SpaceMono because we use it in HomeScreen.js. Feel free
// to remove this if you are not using it in your app
'scala-sans-regular': require('./assets/fonts/ScalaSans-Regular.ttf'),
'scala-sans-bold': require('./assets/fonts/ScalaSans-Bold.ttf'),
}),
])
};
private handleLoadingError = error => {
// In this case, you might want to report the error to your error
// reporting service, for example Sentry
logError("_handleLoadingError", {
error: error
});
console.warn(error);
};
private handleFinishLoading = () => {
this.setState({ isLoadingComplete: true });
};
,这里是由打字稿编译器给出的错误,伤心地说,我不知道是什么要我做什么