0

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.

2
  • You mean when you have this expression the template ? Commented Jan 13, 2023 at 13:59
  • Its in the environment.prod.ts file. Commented Jan 13, 2023 at 14:05

1 Answer 1

1

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;
Sign up to request clarification or add additional context in comments.

1 Comment

You put me on the right track.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.