Vue 3 推荐的 TypeScript TSConfig compilerOptions TARGET 设置?

Vue 3 recommended TypeScript TSConfig compilerOptions TARGET setting?

这个问题让我在使用 Vue 2 和 Vue CLI 时的几个方面感到困惑,现在又开始了一个新的 Vue 3.0 beta 项目。

Even with the currently newest Vue CLI version 4.3.1, when choosing TypeScript option, the boilerplate code you are given has compilerOptions target set as esnexttsconfig.json.

Vue 2 TypeScript Guide 指导期间:

# Recommended Configuration
// tsconfig.json
{
  "compilerOptions": {
    // this aligns with Vue's browser support
    "target": "es5",
    // this enables stricter inference for data properties on `this`
    "strict": true,
    // if using webpack 2+ or rollup, to leverage tree shaking:
    "module": "es2015",
    "moduleResolution": "node"
  }
}

目前 Vue Next repo is using esnext,虽然此时 IE11 支持还没有准备好(但无论如何可能不会影响此配置)...

使用 Vue 3 时,此编译器目标的推荐设置是什么?

我需要支持低至 IE11 的旧版浏览器,但是这个特定的应用程序项目在初始版本发布之前有足够的时间等待 Vue 3 的完整版本。

Vue 3 repository所述,

the current implementation requires native ES2015+ in the runtime environment and does not support IE11 (yet). The IE11 compatible build will be worked on after we have reached RC stage.

如前所述,Vue 3 目前的目标是 esnext,它依赖于现代 JS 功能,目前针对常绿浏览器的开发,不应该用于生产。即使目标较低,Vue 3 也不能在旧版浏览器中使用,因为它目前依赖于代理,这些代理是无法填充的 ES6 功能。

使用现有 Vue 3 构建的项目不会受益于 target 低于 es2018 这可能是最不常见的分母,对象传播是最近使用的最流行的添加之一Vue 3 代码库,不能填充。可以实验性地将 TypeScript 目标降低到 es5,并启用 downlevelIteration 选项,以便及早发现一些兼容性问题。

预计将为旧版 (IE11) 和现代浏览器维护单独的 Vue 3 版本。区别在于反应性的处理方式,因为 Proxy 允许进行高级更改检测,但不能在旧版浏览器中实现。该项目应遵循 Vue 2 reactivity 的现有指南,以便与旧版 Vue 3 构建兼容。