Unexpected keyword 'const'. Const declarations are not supported in strict mode
See original GitHub issueCurrent Behavior
When running a new app using haul with Typescript I get Unexpected keyword 'const'. Const declarations are not supported in strict mode.
. This appears to have happened previously in https://github.com/callstack/haul/issues/159, but according to that ticket it was solved several versions ago by excluding pretty-format
in 58c17ff. I’m on the latest version of haul and am seeing it happen.
Expected Behavior
The error doesn’t occur.
Haul Configuration (webpack.haul.js)
I followed the Typescript setup instructions:
webpack.haul.js
:
module.exports = ({ platform }, { module, resolve }) => ({
entry: `./index.js`,
module: {
...module,
rules: [
{
test: /\.tsx?$/,
exclude: /node_modules/,
use: [
{
loader: 'babel-loader',
},
{
loader: 'ts-loader'
},
],
},
...module.rules
]
},
resolve: {
...resolve,
extensions: [
'.ts',
'.tsx',
`.${platform}.ts`,
'.native.ts',
`.${platform}.tsx`,
'.native.tsx',
...resolve.extensions],
},
});
tsconfig.json
:
{
"compilerOptions": {
"declaration": false,
"lib": ["es2015"],
"module": "es6",
"moduleResolution": "node",
"jsx": "react",
"target": "es2015",
"allowSyntheticDefaultImports": true,
"strictNullChecks": true,
"noImplicitThis": true,
"baseUrl": "."
},
"exclude": [
"node_modules"
],
"compileOnSave": false
}
.babelrc
:
{
"presets": ["react-native"]
}
Your Environment
software | version |
---|---|
Haul | 1.0.0-beta.13 |
react-native | 0.55.1 |
node | both 9.11.1 and 8.11.1 |
yarn | 1.3.2 |
Thanks for any help!
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:10 (5 by maintainers)
Top Results From Across the Web
SyntaxError: Unexpected keyword 'const'. Const declarations ...
SyntaxError: Unexpected keyword 'const'. Const declarations are not supported in strict mode. Issue #9712 · babel/babel · GitHub.
Read more >bundle.js:1 SyntaxError: Unexpected keyword 'const'. Const ...
js:1 SyntaxError: Unexpected keyword 'const'. Const declarations are not supported in strict mode. My webpack.config.json has this rule: rules: ...
Read more >Vue-cli and iOS 9 SyntaxError: Unexpected keyword 'const ...
Const declarations are not supported in strict mode. The const keyword comes from the email-regex lib wich is not tranformed by babel.
Read more >React native unexpected keyword const const declarations ...
536,965 react native unexpected keyword const const declarations are not supported in strict mode jobs found, pricing in USD.
Read more >Const Keyword Is Not Allowded In The Strict Mode In React ...
When running a new app using haul with Typescript I get Unexpected keyword 'const'. Const declarations are not supported in strict mode. Hello...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I am still facing this error when running android release?
Happens to me as well since RN 0.54, and I found the problematic file:
node_modules/metro/src/lib/bundle-modules/MetroClient.js
, so now we have an additional lib to traspile explicitly.Added
metro
tonode_modules/haul/src/utils/makeReactNativeConfig.js
and it works: