Microsoft/TypeScript

"const" was transformed to "var" when target is "esnext"

Open

#59,877 创建于 2024年9月6日

在 GitHub 查看
 (3 评论) (0 反应) (0 负责人)TypeScript (6,726 fork)batch import
BugDomain: JS EmitHelp Wanted

仓库指标

Star
 (48,455 star)
PR 合并指标
 (平均合并 6天 17小时) (30 天内合并 9 个 PR)

描述

🔎 Search Terms

transform, const, var, target, ECMA, esnext

🕗 Version & Regression Information

  • This is the behavior in every version I tried from Version 5.4 to Version 5.7.0-dev.20240904

⏯ Playground Link

No response

💻 Code

export const cilBlurLinear : string [ ] = [  ,  ] 
const [ ,  ] = cilBlurLinear;

🙁 Actual behavior

The JS code generated by tsc is as follows:

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.cilBlurLinear = void 0;
exports.cilBlurLinear = [,];
var ;

🙂 Expected behavior

“const” should be translated as "const" instead of "var", as the target in my configuration file is "esnext".

Additional information about the issue

tsconfig.json:

{
  "compilerOptions": {
    "target": "ESNext",
    "module": "esnext",
    "moduleResolution": "Node",
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,
    "lib": ["es2023","dom"],
    "noEmitOnError":true,
    "force":true,
    "strict":true
  },
  "include": [
    "TScorpus/*"
  ],
  "exclude": [
    "node_modules"
  ]
}

贡献者指南