最近发现编译后的 JS 代码里出现很多 'xxx'.concat() 代码。字符串拼接从不用这个方法,一排查才发现原来不什么时候开始 typescript 把字符串模板转换成这种风格。。
比如:
`aa${x}bb`
变成:
'aa'.concat(x, 'bb')
本来用 + 拼接字符串,minify 时有些常量可以直接合并掉,现在用了 concat 方法就合并不了,太蛋疼。。。
最近发现编译后的 JS 代码里出现很多 'xxx'.concat() 代码。字符串拼接从不用这个方法,一排查才发现原来不什么时候开始 typescript 把字符串模板转换成这种风格。。
比如:
`aa${x}bb`
变成:
'aa'.concat(x, 'bb')
本来用 + 拼接字符串,minify 时有些常量可以直接合并掉,现在用了 concat 方法就合并不了,太蛋疼。。。
|
1
|
|
dany813Apr 20, 2022
2
```
The change was publicly released in TypeScript 4.4.2 (4.4.0 and 4.4.1 were beta and RC versions, respectively). ``` |
|
learningmanApr 20, 2022
3
把 target 改成 ES6+就好了(
|