-
Notifications
You must be signed in to change notification settings - Fork 12.8k
use sys based host for formatting diagnostics #9750
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
Conversation
Heh. I just hit this! |
getCanonicalFileName: createGetCanonicalFileName(sys.useCaseSensitiveFileNames) | ||
}; | ||
|
||
let reportDiagnosticWorker = reportDiagnosticSimply; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: why you are doing this instead of just call reportDiagnosticSimply
directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because reportDiagnosticWorker
can be either reportDiagnosticSimply
or reportDiagnosticWithColorAndContext
if pretty
option is set
lgtm with small comment & question. |
use sys based host for formatting diagnostics
@@ -991,7 +991,13 @@ namespace ts { | |||
return sortAndDeduplicateDiagnostics(diagnostics); | |||
} | |||
|
|||
export function formatDiagnostics(diagnostics: Diagnostic[], host: CompilerHost): string { | |||
export interface FormatDiagnosticsHost { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please clarify this interface? Thanks a lot!
- It's a contract between which part of the system and which other part?
- Who is meant to provide the implementation?
- Do existing host scenarios need to do anything?
- Maybe a use case please?
Sorry for being inquisitive, but there are a few other *Host
interfaces at various levels of abstraction, it becomes harder to follow. Please give us a picture why FormatDiagnosticsHost
is there, beyond self-evident 'to deal with diagnostic formatting'. I am sure others will benefit from the same, especially where TS is an embedded library.
Many thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a subset of CompilerHost/sys functionality - specifically the minimal subset needed to properly format diagnostics. Like how use use ModuleResolutionHost to indicate where we need the minimal functionality for resolving modules. Grouping the methods needed into a "host" like this is simply cleaner than passing in a collection of arguments or closures directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @weswigham!
Although that sort of rephrases "Format Diagnostics Host" rather than answers any of the questions above ;-)
fixes #9749