Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Identity function should be inlined #510

Closed
michens opened this issue Nov 12, 2019 · 1 comment
Closed

Identity function should be inlined #510

michens opened this issue Nov 12, 2019 · 1 comment

Comments

@michens
Copy link
Contributor

michens commented Nov 12, 2019

Feature request

In TypeScript, it's frequently convenient to write an identity function to simplify type conversions.
Unfortunately, the definitions and calls continue to remain after invoking Terser.
Is it possible to get Terser to optimize this case?

Version (complete output of terser -V or specific git commit)
4.4.0

Complete CLI command or minify() options used

{}

Also tried explicitly setting inline:

{
  compress: {
    inline: true
  }
}

terser input

const id = x => x;
const repro = [id(1), id(2)];
console.log(repro);

terser output or error

const id=o=>o,repro=[id(1),id(2)];console.log(repro);

Expected result

const repro=[1,2];console.log(repro);

or even:

console.log([1,2])
@fabiosantoscode
Copy link
Collaborator

Sounds like a great idea! I love the identity function but in this case I'm not sad to see it go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants