• 请不要在回答技术问题时复制粘贴 AI 生成的内容
iqoo
V2EX  ›  程序员

typescript 把字符串模板转成 concat 方法了

  •  
  •   iqoo · Apr 19, 2022 · 1720 views
    This topic created in 1499 days ago, the information mentioned may be changed or developed.

    最近发现编译后的 JS 代码里出现很多 'xxx'.concat() 代码。字符串拼接从不用这个方法,一排查才发现原来不什么时候开始 typescript 把字符串模板转换成这种风格。。

    比如:

    `aa${x}bb`
    

    变成:

    'aa'.concat(x, 'bb')
    

    本来用 + 拼接字符串,minify 时有些常量可以直接合并掉,现在用了 concat 方法就合并不了,太蛋疼。。。

    3 replies    2022-04-20 08:59:57 +08:00
    dany813
        2
    dany813  
       Apr 20, 2022
    ```
    The change was publicly released in TypeScript 4.4.2 (4.4.0 and 4.4.1 were beta and RC versions, respectively).
    ```
    learningman
        3
    learningman  
       Apr 20, 2022
    把 target 改成 ES6+就好了(
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4151 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 10:11 · PVG 18:11 · LAX 03:11 · JFK 06:11
    ♥ Do have faith in what you're doing.