javascript - global.HermesInternal - 属性 'HermesInternal' 在类型 'Global & typeof globalThis' 上不存在
问题描述
我有下面的代码,自动生成:
$ react-native init RepeatAloud
应用程序.tsx
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow strict-local
*/
import React from 'react';
import {
SafeAreaView,
StyleSheet,
ScrollView,
View,
Text,
StatusBar,
} from 'react-native';
import {
Header,
LearnMoreLinks,
Colors,
DebugInstructions,
ReloadInstructions,
} from 'react-native/Libraries/NewAppScreen';
const App: () => React.ReactNode = () => {
return (
<>
<StatusBar barStyle="dark-content" />
<SafeAreaView>
<ScrollView
contentInsetAdjustmentBehavior="automatic"
style={styles.scrollView}>
<Header />
{global.HermesInternal == null ? null : (
<View style={styles.engine}>
<Text style={styles.footer}>Engine: Hermes</Text>
</View>
)}
<View style={styles.body}>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>Step One</Text>
<Text style={styles.sectionDescription}>
Edit <Text style={styles.highlight}>App.js</Text> to change this
screen and then come back to see your edits.
</Text>
</View>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>See Your Changes</Text>
<Text style={styles.sectionDescription}>
<ReloadInstructions />
</Text>
</View>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>Debug</Text>
<Text style={styles.sectionDescription}>
<DebugInstructions />
</Text>
</View>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>Learn More</Text>
<Text style={styles.sectionDescription}>
Read the docs to discover what to do next:
</Text>
</View>
<LearnMoreLinks />
</View>
</ScrollView>
</SafeAreaView>
</>
);
};
const styles = StyleSheet.create({
scrollView: {
backgroundColor: Colors.lighter,
},
engine: {
position: 'absolute',
right: 0,
},
body: {
backgroundColor: Colors.white,
},
sectionContainer: {
marginTop: 32,
paddingHorizontal: 24,
},
sectionTitle: {
fontSize: 24,
fontWeight: '600',
color: Colors.black,
},
sectionDescription: {
marginTop: 8,
fontSize: 18,
fontWeight: '400',
color: Colors.dark,
},
highlight: {
fontWeight: '700',
},
footer: {
color: Colors.dark,
fontSize: 12,
fontWeight: '600',
padding: 4,
paddingRight: 12,
textAlign: 'right',
},
});
export default App;
我得到以下错误:
Property 'HermesInternal' does not exist on type 'Global & typeof globalThis'.
正如你在这里看到的:
有没有办法处理这个?
谢谢!
解决方案
从技术上讲,您不需要它。这只是为了检查您的 Hermes 设置是否正确。为此,您可以禁用对该行的类型检查。
这里有一个建议
https://github.com/react-native-community/react-native-template-typescript/pull/78/files
推荐阅读
- elasticsearch - Elasticsearch 中只显示 10 条记录
- python - 通过将 csv 插入数据库的 KeyError?
- php - strtotime() 期望参数 1 是字符串,在 codeigniter 中给出的数组
- c# - 如何填写文本框?
- amazon-web-services - 连接 AWS Api Gateway 和私有 ALB
- android - 如果 Firestore 数据库发生变化,我是否会再次阅读所有文档?
- python-3.x - 在打包机器人中获取客户端位置
- python - readlines 函数在应用于从网页响应获得的文件时抛出错误
- java - 为什么数组类型的类变量在声明后无法初始化,但可以在Java中的方法内部初始化?
- javascript - Photoshop JavaScript (ExtendScript):如何在脚本完成之前显示图层?