This is app.tsx
{global.HermesInternal == null ? null : (
<View style={styles.engine}>
<Text style={styles.footer}>Engine: Hermes</Text>
</View>
)}
This is package.json
"devDependencies": {
"@babel/core": "^7.5.0",
"@babel/runtime": "^7.5.0",
"@react-native-community/eslint-config": "^0.0.3",
"@types/jest": "^24.0.15",
"@types/react": "^16.9.2",
"@types/react-native": "^0.60.15",
"@types/react-test-renderer": "^16.8.2",
"babel-jest": "^24.1.0",
"jest": "^24.1.0",
"metro-react-native-babel-preset": "^0.54.1",
"react-native-typescript-transformer": "^1.2.13",
"react-test-renderer": "16.8.6",
"typescript": "^3.6.3"
},
I get a type error message from Intellij only "Unresolved variable of type global", but the app runs successfully. I tried adding @types/node and then a type error about HermesInternal not being part of global object is thrown.
Just for refernce in @types/react-native/index.d.ts this is the declaration:
declare global {
...
const HermesInternal: null | {};
}
I suspect this is a problem with the react native typings. As you've seen, the typings export a global HermesInternal object, but they don't declare the global parent object itself.
As a workaround, you can include this declaration above your component:
declare global {
const global: { HermesInternal: null | {} }
}
Not ideal, but hopefully we will see an updated typings file to fix this issue. I'm currently on @types/[email protected].
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With