question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add `--inlineConsts` flag

See original GitHub issue

New flag --inlineConsts

Input:

const x = 'hello';

console.log(x);

Output:

console.log('hello');

See also #6678 + #6804

TBD: It’s not clear you would want longer strings to inline into their use sites. Discuss.

Issue Analytics

  • State:open
  • Created 8 years ago
  • Reactions:8
  • Comments:20 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
alitahericommented, Oct 29, 2016

This feature can actually decrease file size sometimes when combined with tools like uglify. Usually with conditionals:

const myConst = "blah";

// ...

// this code can be safely removed after myConst gets replaced with "blah"
if (myConst !== "blah") {
 // ...
}
1reaction
dead-claudiacommented, Jul 9, 2019

@Raiondesu declare in TS is about declaring bindings, specifically bindings with no immediate value, not changing their instantiation.

In my experience, I’ve never once stumbled across a use case where a primitive constant would’ve been better not inlined, even in perf-critical code. If you’re worried about duplication, gzip can make quick work of that. About the only two places I could imagine it being useful to not inline a constant is in embedded applications and with very large strings used in multiple unrelated places. In the first, you need enough control that you’d do better (ab)using const enums for constants than using const + --inlineConsts. In the second, you can work around it with wrapping it in an object, but it doesn’t appear large strings are guaranteed to make it, either.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Suggestion Backlog Slog, 8/19/2019 #32981 - GitHub
PR #32802 - flag non-calls to boolean functions in if expressions PR #28372 - add ES3.d.ts ... Add --inlineConsts flag #6805 --inlineConsts ......
Read more >
llvm Namespace Reference
This namespace holds all of the target specific flags that instruction info ... Add a small namespace to avoid name clashes with the...
Read more >
web.mit.edu/nim-lang_v0.16.0/nim-0.16.0/compiler/s...
getOrdValue(idx): localError(x.info, errInvalidOrderInArrayConstructor) x = x.sons[1] let xx = semExprWithType(c, x, flags*{efAllowDestructor}) result.add ...
Read more >
R600.patch - FreeDesktop.Org
getNode(ISD::ADD, DL, VT, RCP, E); + + // RCP_S_E = RCP - E + SDValue RCP_S_E ... + ArenaVectors = 0x17, // Flag...
Read more >
Diff - platform/tools/metalava - android Git repositories
newName(), + listOf( + // Add "L" suffix to ensure that we don't for example interpret "-1" ... getAttribute(ATTR_NAME)) flag = VALUE_TRUE ==...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found