# UXP removes (optimizes out) a variable that is being used / Bug

**URL:** <https://forums.creativeclouddeveloper.com/t/uxp-removes-optimizes-out-a-variable-that-is-being-used-bug/11723>\
**Category:** Premiere Pro\
**Tags:** bug, uxp\
**Created:** [February 18, 2026, 10:15pm UTC](https://forums.creativeclouddeveloper.com/t/uxp-removes-optimizes-out-a-variable-that-is-being-used-bug/11723 "2026-02-18T22:15:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MarcClown](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/marcclown/32/4778_2.png) [@MarcClown](https://forums.creativeclouddeveloper.com/u/MarcClown)\
**Post date:** [February 18, 2026, 10:15pm UTC](https://forums.creativeclouddeveloper.com/t/uxp-removes-optimizes-out-a-variable-that-is-being-used-bug/11723/1 "2026-02-18T22:15:52Z")

</div>

FYI

I seems I hit a but where apparently UXP is optimizing out a variable that is being used.  
( Note: `fileToTranscriptLUT` has been defined as a `Map()` and initialized prior to the call)

This fails (“transcript” is unassigned, and “unassigned” is passed to the function)

```javascript
    if (start.indexOf("+") > 0) {
      const transcript = fileToTranscriptLUT.get(sourceFile)
      [start, end] = getStartAndEnd(text, start.slice(0,-1), end, transcript)
    }

```

… but this works fine (value associated with sourceFile is returned as expected and passed to the function):

```javascript
   if (start.indexOf("+") > 0) {
      const transcript = fileToTranscriptLUT.get(sourceFile)
      typeof(transcript); // looks useless but needed to work around bug
      [start, end] = getStartAndEnd(text, start.slice(0,-1), end, transcript)
    }

```

It seems like the engine is trying to optimize the variable transcript out (despite being passed to function just below).  
The extra line using the variable as well (`typeof(transcript)`) to prevent the engine from optimizing it out (it worked as well when I was logging the variable `logWarning(transcript)` instead of that line).

---

<div class="post-metadata">

**Author:** ![Dirk](https://avatars.discourse-cdn.com/v4/letter/d/87869e/32.png) [@Dirk](https://forums.creativeclouddeveloper.com/u/Dirk)\
**Post date:** [February 20, 2026, 4:41am UTC](https://forums.creativeclouddeveloper.com/t/uxp-removes-optimizes-out-a-variable-that-is-being-used-bug/11723/2 "2026-02-20T04:41:24Z")

</div>

Modern JS syntax additions have their downsides.

A semicolon at the end of the const … statement should do. Otherwise the statement is continued with the stray array index [start,end] . The chained assignment sets yourGetResult[end] before the result of that assignment - the assigned value - is stored in the const.

---

<div class="post-metadata">

**Author:** ![MarcClown](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/marcclown/32/4778_2.png) [@MarcClown](https://forums.creativeclouddeveloper.com/u/MarcClown)\
**Post date:** [February 21, 2026, 1:42am UTC](https://forums.creativeclouddeveloper.com/t/uxp-removes-optimizes-out-a-variable-that-is-being-used-bug/11723/3 "2026-02-21T01:42:47Z")

</div>

Great, thank you @Dirk !

Too much Python coding over the years pushed me into bad habits indeed.  
I’ll start put those semi-colon back in my JavaScript to avoid that type of issues in the future 🙂

( Note to self: treat JS syntax more like C than Python )
