[@types/node] 3x properties on process.stdout & process.stderr should be marked "?" (optional/undefined): .columns + .rows + .isTTY #69230
Replies: 3 comments
-
Thanks for the discussion about "node", some useful links for everyone: Pinging the DT module owners: @microsoft, @jkomyno, @alvis, @r3nya, @btoueg, @smac89, @Touffy, @DeividasBakanas, @eyqs, @Hannes-Magnusson-CK, @hoo29, @kjin, @ajafff, @islishude, @mwiktorczyk, @mohsen1, @galkin, @parambirs, @eps1lon, @ThomasdenH, @WilcoBakker, @wwwy3y3, @samuela, @kuehlein, @bhongy, @chyzwar, @trivikr, @yoursunny, @qwelias, @ExE-Boss, @peterblazejewicz, @addaleax, @victorperin, @ZYSzys, @nodejs, @LinusU, @wafuwafu13, @mcollina, @Semigradsky. |
Beta Was this translation helpful? Give feedback.
-
Here's a quick bash shell command you can run to see the non-interactive output piped through
Remove the |
Beta Was this translation helpful? Give feedback.
-
Location:
DefinitelyTyped/types/node/tty.d.ts
Lines 187 to 203 in 41aa59f
undefined
when Node isn't running on an interactive terminal, e.g. in all these situations:> /tmp/output.txt
or another process| less
Some testing code:
✔️ If you run the code above in a regular interactive terminal, all is good, you get something like...
❌ If it's not an interactive terminal, all 3 of those properties are
undefined
:So the types should be optional:
process.stdout
+process.stderr
Missing methods
Additionally, the
.getWindowSize()
+.hasColors()
methods (and probably more) don't even exist when non-interactive...✔️ Interactive output:
🔥 Non-interactive will throw exceptions:
Beta Was this translation helpful? Give feedback.
All reactions