buenon / scratchpads

Scratchpads extension for Visual Studio Code
MIT License
27 stars 10 forks source link

Typescript scratchpads share the same namespace #39

Open DanKaplanSES opened 1 year ago

DanKaplanSES commented 1 year ago

Summary

All open typescript scratchpad's share the same namespace. This means they can read each other's variables. Defining x in two typescript scratchpads results in an error because it's already defined in the other scratchpad. I would like each typescript scratchpad to have its own namespace. Or, in other words, I think each scratchpad should run in its own sandbox.

I don't think scratchpads worked this way in the past so I'm assuming this is a bug? If it is intentional behavior, I'm happy to provide reasons for my feature request.

Steps to reproduce

  1. Create a new Typescript scratchpad
  2. Write const x = 1; as its content.
  3. Create another new Typescript scratchpad
  4. Write const x = 1; as its content.

Expected: Both scratchpad's exist without error Actual: Both scratchpad's error:

Cannot redeclare block-scoped variable 'x'. ts(2451)
scratch34.ts(1, 7): 'x' was also declared here.

Note: Closing one of the two scratchpad's (or both) fixes the problem.