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

pretty option is ignored in terminal #1418

Closed
elevatebart opened this issue Aug 5, 2021 · 4 comments · Fixed by #1420
Closed

pretty option is ignored in terminal #1418

elevatebart opened this issue Aug 5, 2021 · 4 comments · Fixed by #1420
Milestone

Comments

@elevatebart
Copy link
Contributor

Expected Behavior

When I specify pretty: false I expect the errors to respect that.
This is particularly useful if I am developing a tool that uses ts-node and I need to handle 3rd party potentially faulty code.

Actual Behavior

Because of this line, when I use a terminal as the main output for my tool, pretty is ignored:

ts-node/src/index.ts

Lines 628 to 630 in e8a4d76

const formatDiagnostics =
process.stdout.isTTY || options.pretty
? ts.formatDiagnosticsWithColorAndContext || ts.formatDiagnostics

Steps to reproduce the problem

Run ts-node on a faulty codebase with --pretty false option.
Errors are still styled with terminal only decoration.

Minimal reproduction

TypeStrong/ts-node-repros#16

Specifications

ts-node v8.3.0
node v14.17.0
compiler v4.3.5

tsconfig.json

{
  "compilerOptions":{
    "pretty": false
  }
}
  • Operating system and version: MacOS - Big Sur
@cspotcode
Copy link
Collaborator

cspotcode commented Aug 5, 2021

Sounds like we want 3x states for the pretty flag: true forces it enabled, false forces it disabled, and undefined (not specified anywhere) allows the default to be determined based on isTTY. Does that sound reasonable?

Are you able to send a pull request for this?

@cspotcode
Copy link
Collaborator

The docs will need to be updated to match, as well.
https://typestrong.org/ts-node/docs/options/#diagnostics

@elevatebart
Copy link
Contributor Author

I'll whip up a PR right now.
I don't see where this is tested though.
Do you know if it is tested at all?

@cspotcode
Copy link
Collaborator

I replied to the PR before seeing this comment.

It might be untested. Most of the tests invoke the CLI, which isn't the fastest but is simple to think about. Feel free to write a couple tests that do that.

@cspotcode cspotcode added this to the 10.x.x milestone Aug 5, 2021
cspotcode added a commit that referenced this issue Aug 8, 2021
* fix: allow to specify pretty errors in TTY

closes #1418

* lint fix

Co-authored-by: Andrew Bradley <cspotcode@gmail.com>
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

Successfully merging a pull request may close this issue.

2 participants