We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
eval?.()
1 parent 3cb4944 commit 7290646Copy full SHA for 7290646
test/com/google/javascript/jscomp/RewriteOptionalChainingOperatorTest.java
@@ -91,6 +91,18 @@ public static class BaseTestClass extends CompilerTestCase {
91
public static final ImmutableList<Object> cases() {
92
return ImmutableList.copyOf(
93
new Object[][] {
94
+ {
95
+ "eval?.('foo()');",
96
+ lines(
97
+ "let tmp0;", //
98
+ "(tmp0 = eval) == null",
99
+ " ? void 0",
100
+ // The spec says that `eval?.()` must behave like an indirect
101
+ // eval, so it is important that `eval?.()` not be transpiled to
102
+ // anything that ends up containing `eval()`.
103
+ // We must be sure to call it using the temporary variable.
104
+ " : tmp0('foo()');")
105
+ },
106
{
107
"obj?.ary[getNum()].obj.obj?.obj.ary",
108
lines(
0 commit comments