-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Closed
Closed
Copy link
Labels
Spec: Optional Chainingi: browser bugoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issueA closed issue/PR that is archived due to age. Recommended to make a new issue
Description
Bug Report
- I would like to work on a fix!
Current behavior
There's a bug in Chrome when invoking a bare optional call (not a method on an object) when there is a spread arguments and a following argument:
Input Code
REPL (Chome throws, Firefox/Safari are fine)
const fn = null;
const n = null;
const o = {};
// Fine
fn?.(...[]);
o?.toString(...[], 1);
o?.toString?.(...[], 1);
n?.method?.(...[], 1);
// Throws (must be any argument that follows a ...spread)
fn?.(...[], 1);
fn?.(...[], ...[]);
o.method?.(...[], 1);
// This one is most surprising!
n?.method(...[], 1);Expected behavior
None of these should throw in Chrome
Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)
- Filename:
babel.config.js
{
"presets": [
[
"@babel/preset-env",
{
"targets": "Chrome > 80",
"bugfixes": true
}
]
]
}Possible Solution
We need to add a new bugfix transform that detects these ...foo spread arguments inside an optional chain, and forces the transform.
Additional context
Edits by @JLHwung
- Added link to v8 issue for reference.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Spec: Optional Chainingi: browser bugoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issueA closed issue/PR that is archived due to age. Recommended to make a new issue