简体   繁体   English

Vue 3 推荐 TypeScript TSConfig compilerOptions TARGET 设置?

[英]Vue 3 recommended TypeScript TSConfig compilerOptions TARGET setting?

This question has puzzled me at several points when using Vue 2 and Vue CLI, and now again with starting a fresh Vue 3.0 beta project.在使用 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 esnext in tsconfig.json . 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 esnext in tsconfig.json .

While Vue 2 TypeScript Guide is instructing:虽然Vue 2 TypeScript 指南指示:

# 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"
  }
}

Currently Vue Next repo is using esnext , although at this point IE11 support is not ready yet (but might not affect this config anyhow)...目前Vue Next repo 正在使用esnext ,尽管此时 IE11 支持尚未准备好(但无论如何可能不会影响此配置)...

What will be the recommended setting for this compiler target when using Vue 3?使用 Vue 3 时,此编译器目标的推荐设置是什么?

I'm needing to support legacy browsers down to IE11, but this particular app project has plenty of time until it's initial release to wait for Vue 3's full release.我需要支持低至 IE11 的旧版浏览器,但是这个特定的应用程序项目在其初始发布之前有足够的时间等待 Vue 3 的完整发布。

As Vue 3 repository states,正如Vue 3 存储库所述,

the current implementation requires native ES2015+ in the runtime environment and does not support IE11 (yet).当前的实现需要在运行时环境中使用本机 ES2015+,并且不支持 IE11(目前)。 The IE11 compatible build will be worked on after we have reached RC stage. IE11 兼容版本将在我们达到 RC 阶段后进行。

As it was noted, the target of Vue 3 is currently esnext , it relies on modern JS features and is currently aimed at the development in evergreen browsers and isn't supposed to be used in production.如前所述,Vue 3 的目标目前是esnext ,它依赖于现代 JS 功能,目前针对的是常青浏览器的开发,不应该在生产中使用。 Vue 3 cannot be usable in legacy browsers even with lower target because it currently relies on proxies which are ES6 feature that cannot be polyfilled.即使目标较低,Vue 3 也无法在旧版浏览器中使用,因为它目前依赖于无法填充的 ES6 特性的代理。

The project that uses existing Vue 3 build won't benefit from target lower than es2018 which is likely the least common denominator, object spread is among most popular recent additions that is used in Vue 3 codebase and cannot be polyfilled.使用现有 Vue 3 构建的项目不会受益于低于es2018target ,这可能是最不常见的分母,object spread 是最近在 Vue 3 代码库中使用的最流行的新增功能之一,无法进行 polyfill。 TypeScript target can be experimentally lowered to es5 with downlevelIteration option enabled for early detection of some compatibility problems. TypeScript 目标可以通过启用downlevelIteration选项的实验性降低到es5 ,以便及早检测一些兼容性问题。

It's expected that separate versions of Vue 3 will be maintained for legacy (IE11) and modern browsers.预计将为旧版(IE11)和现代浏览器维护单独的 Vue 3 版本。 The difference is how reactivity is handled because Proxy allows for advanced change detection but cannot be implemented in legacy browsers.不同之处在于如何处理响应性,因为Proxy允许高级更改检测,但不能在旧版浏览器中实现。 The project should follow existing guidelines for Vue 2 reactivity in order to be compatible with legacy Vue 3 build.该项目应遵循Vue 2 反应性的现有指南,以便与旧版 Vue 3 构建兼容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在tsconfig.json中,compilerOptions.target指定了什么? - What does compilerOptions.target specify in tsconfig.json? 如何使用--outDir TypeScript编译器选项 - How to use --outDir TypeScript compilerOptions tsconfig.json 设置中的目标不起作用但命令有效? - target in tsconfig.json setting not working but command works? 设置 Meteor、Vue 和 Typescript - Setting up Meteor, Vue and Typescript Vue + TypeScript-用于放置自定义类型的推荐文件夹结构约定? - Vue + TypeScript - Recommended folder structure convention for placing custom typings? TypeScript。 在 tsconfig.json 中使用 ESNext 作为目标时如何防止转译? - TypeScript. How prevent transpiling while using ESNext as a target in tsconfig.json? 可以更改TypeScript CompilerOptions-> lib与NPM软件包或依赖项的冲突 - Can changing TypeScript compilerOptions->lib conflict with NPM Packages or Dependencies Google Closure Compiler:通过设置CompilerOptions删除无效代码 - Google Closure Compiler: remove dead code by setting CompilerOptions tsconfig.json 中 TARGET 属性的影响 - Effect of TARGET property inside tsconfig.json 某些文件夹中的TypeScript tsconfig输出文件 - TypeScript tsconfig Output files in certain folders
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM