Google Apps 脚本 - 可选链接抛出 ParseError

Google Apps Script - optional chaining throwing ParseError

为什么 google Apps 脚本不支持最新的 javascript 功能,例如可选链接,即使它是 运行 在 Chrome V8 上?使用可选链接时,clasp 会抛出错误。

GaxiosError: Syntax error: ParseError: Unexpected token .

运行环境已经在清单文件appsscript.json中提到为:

{
    ...
    "runtimeVersion": "V8",
    ...
}

目前不支持此功能(可选链接)。 A bug report 被 Google 提出并被拒绝:

Status: Won't Fix (Infeasible) Hello, Currently this operator does not work on Apps Script. V8 allows you to run modern syntax, but not all of the newly released features. You can check the information in ⁠V8 Runtime Overview To sum up, apps script v8 is not javascript. Regards.

但是您可以提出 feature request 相同的问题(这不是错误报告)。