-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BigInt literal support still missing #34603
Comments
According to this blog post, support for BigInt is ongoing. https://reactnative.dev/blog/2022/07/08/hermes-as-the-default#ongoing-work |
Hello @thalesfp Change Log 0.70 Support BigInt in Hermes, please check this link: https://github.com/facebook/react-native/blob/main/CHANGELOG.md#added const bI = BigInt(1) it is working |
…form Summary: Context: `Math.pow(a, b)` throws when `a` or `b` is a BigInt, while `a ** b` evaluates to a BigInt in that case. This makes [`babel/plugin-transform-exponentiation-operator`](https://babeljs.io/docs/en/babel-plugin-transform-exponentiation-operator) unsafe in code that uses BigInts. See also facebook/react-native#34656, facebook/react-native#34603. Here we remove the plugin from the React Native Babel preset. This is safe to do because: 1. Hermes supports the `**` operator [natively](facebook/hermes@ae0bc93). 2. JSC on iOS has supported the `**` operator natively since version 10.3 (source: [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Exponentiation#browser_compatibility)), and React Native targets iOS 12.4+. 3. The version of JSC React Native uses on Android ([jsc-android@v250230.2.1](https://github.com/react-native-community/jsc-android-buildscripts/releases/tag/v250230.2.1)) is based on [WebKit commit 250230](https://commits.webkit.org/250230@main) which [supports](https://github.com/WebKit/WebKit/blob/1d27863e32855c7fe51d5de1aae0589f11a428be/Source/JavaScriptCore/features.json#L170-L185) the `**` operator. 4. Metro now uses Terser as the default minifier (#871) which includes support for modern language features such as the `**` operator. Changelog: * **[Fix]** Remove exponentiation operator transform from `metro-react-native-babel-preset`. NOTE: This is a fix and not a breaking change because `metro-react-native-babel-preset` is *already* meant for use only with current React Native versions, where the `**` operator is supported natively (as shown above). Reviewed By: huntie Differential Revision: D39683437 fbshipit-source-id: 67d84e7a9eecf27e40b7d7b9d4b3666a4201fec1
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
This issue was closed because it has been stalled for 7 days with no activity. |
Description
After adding this line in newly created project
const bigLiteral = 2n;
Unable to archive
Error: error App.tsx: Unexpected token: name (n) in file App.tsx at 33:22.
Looks like BigInt literal still missing.
Version
0.70.0
Output of
npx react-native info
info Fetching system and libraries information...
System:
OS: macOS 12.4
CPU: (8) arm64 Apple M1
Memory: 127.72 MB / 8.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 18.6.0 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 8.13.2 - /usr/local/bin/npm
Watchman: 2022.08.15.00 - /opt/homebrew/bin/watchman
Managers:
CocoaPods: 1.11.3 - /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5
Android SDK: Not Found
IDEs:
Android Studio: 2021.2 AI-212.5712.43.2112.8609683
Xcode: 13.4.1/13F100 - /usr/bin/xcodebuild
Languages:
Java: 11.0.15 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 18.1.0 => 18.1.0
react-native: 0.70.0 => 0.70.0
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found
Steps to reproduce
Snack, code example, screenshot, or link to a repository
`const App = () => {
const isDarkMode = useColorScheme() === 'dark';
const bigLiteral = 2n;
const backgroundStyle = {
backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
};
return (
<StatusBar
barStyle={isDarkMode ? 'light-content' : 'dark-content'}
backgroundColor={backgroundStyle.backgroundColor}
/>
<View
style={{
backgroundColor: isDarkMode ? Colors.black : Colors.white,
}}>
Edit App.tsx to change this
screen and then come back to see your edits.
Read the docs to discover what to do next:
);
};`
The text was updated successfully, but these errors were encountered: