Allow optional chaining operator in Chromium Web code

174 views
Skip to first unread message

John Palmer

unread,
Sep 27, 2022, 8:01:31 PM9/27/22
to Chromium-dev
Hi,

Looking at https://chromium.googlesource.com/chromium/src/+/HEAD/styleguide/web/es.md it seems that the optional chaining operator (?.) is currently banned.

I would like to request that it be allowed.

It can significantly simplify JS/TS code. For example

If (a) {
   return a.b;
} else {
   return null;
}
can become 

return a?.b;

With multiple property access the if style code can become increasingly complicated, whilst the optional chaining version stays simple.

I believe that the Google Javascript/Typescript style guides allow usage of this language feature.

Some links:

Reilly Grant

unread,
Sep 29, 2022, 4:31:12 PM9/29/22
to jopa...@chromium.org, Chromium-dev
I can't find where in the document you linked the optional chaining operator is banned. Can you provide a direct link?

I know some features weren't allowed in WebUI code because it is shared with Chrome for iOS and we need it to work under WKWebView. It seems like optional chaining is supported in Safari so I'm guessing that isn't the issue.
Reilly Grant | Software Engineer | rei...@chromium.org | Google Chrome


--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/b0a5d18a-6bb4-4d6a-a31f-d36229ace5b6n%40chromium.org.

Torne (Richard Coles)

unread,
Sep 29, 2022, 4:53:25 PM9/29/22
to rei...@chromium.org, jopa...@chromium.org, Chromium-dev
The style guide only lists things up to ES2017 and ?. is from ES2020, so it's unclear which (if any) features from 2018+ are intended to be allowed.

John Palmer

unread,
Sep 29, 2022, 6:55:26 PM9/29/22
to Chromium-dev, Richard Coles, John Palmer, Chromium-dev, Reilly Grant
My understanding based on the first sentence:

> This doc extends the style guide by specifying which new features of ES2015 and beyond are allowed in Chromium.

Is that everything >= ES2015 and beyond not mentioned is banned. So I believe any ES2020 feature is banned (including this specific one).

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev+unsubscribe@chromium.org.

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev+unsubscribe@chromium.org.
Reply all
Reply to author
Forward
0 new messages