-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
Milestone
Description
Bug Report
π Search Terms
syntax error optional chain new arguments parentheses
π Version & Regression Information
Only tested with 4.7 Nightly in the playground
β― Playground Link
Playground link with relevant code
π» Code
class A {
b() {}
}
new A?.b()
Output
"use strict";
var _a;
class A {
b() { }
}
(_a = new A) === null || _a === void 0 ? void 0 : _a.b();
Compiler Options
{
"compilerOptions": {
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictPropertyInitialization": true,
"strictBindCallApply": true,
"noImplicitThis": true,
"noImplicitReturns": true,
"alwaysStrict": true,
"esModuleInterop": true,
"declaration": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"target": "ES2017",
"jsx": "react",
"module": "ESNext",
"moduleResolution": "node"
}
}
Playground Link: Provided
π Actual behavior
new A?.b()
is parsed as if it was new A()?.b()
π Expected behavior
It should be a syntax error, because it's not valid JavaScript syntax.
MartinJohns, fatcerberus, JLHwung, ahmad-ali14 and lgrammel