简体   繁体   中英

Does the Angular Compiler optimize string expressions?

I have the following code snippet:

"foo".length > 0 ? true : false;

Does the Angular compiler replace it just with true ?

tsc does not do; I tried it out.

That's the job of the minifier, noy the compiler.

For example Esbuild (a bundler used by angular) will do that for you:

echo '[1].length > 0 ? true : false' | esbuild --loader=ts --minify
> [1].length>0;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM