-
Notifications
You must be signed in to change notification settings - Fork 207
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
Added diagnostics to all errors #1963
Conversation
Co-authored-by: Dominik Moritz <domoritz@gmail.com>
Next up, I was thinking of rewriting the CLI to use oclif. I did the same thing with kitajs and it's awesome. It auto generates cli documentation, provides autocompletions, automatically creates help commands, detect cli updates and much more automatically. Sample of kitajs cli autocomplete: Sample of kitajs cli help: What do you think? |
Better cli sounds great |
I gave you write permissions to the repo so you can make PRs from internal branches and merge PRs when they are done. |
thanks! |
🚀 PR was released in |
This PR standardizes all errors thrown by this library, which helps every package that uses this code underneath, as well with the end-user using this CLI.
As every errors extends from
TJSGError
, every error may have a.diagnostic
which can be formatted by thets.formatDiagnosticsWithColorAndContext
function.For example, when having a typecheck error, this is what was shown:
VS what is now:
Or, for example, when a node cannot be parsed (I faked the error):
VS what is now:
All errors are serializable and can contain useful information.
In non
tty
environment, such as CI environments, thrown errors doesn't emit ANSI color codes or anything might blowup logs with useless information.Version
Published prerelease version:
v2.3.0-next.0
Changelog
🚀 Enhancement
Authors: 1
📦 Published PR as canary version:
2.3.0--canary.1963.49df2de.0
✨ Test out this PR locally via:
npm install ts-json-schema-generator@2.3.0--canary.1963.49df2de.0 # or yarn add ts-json-schema-generator@2.3.0--canary.1963.49df2de.0