use sys based host for formatting diagnostics#9750
Conversation
|
Heh. I just hit this! |
| getCanonicalFileName: createGetCanonicalFileName(sys.useCaseSensitiveFileNames) | ||
| }; | ||
|
|
||
| let reportDiagnosticWorker = reportDiagnosticSimply; |
There was a problem hiding this comment.
Question: why you are doing this instead of just call reportDiagnosticSimply directly?
There was a problem hiding this comment.
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
| } | ||
|
|
||
| export function formatDiagnostics(diagnostics: Diagnostic[], host: CompilerHost): string { | ||
| export interface FormatDiagnosticsHost { |
There was a problem hiding this comment.
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.
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.
Thanks @weswigham!
Although that sort of rephrases "Format Diagnostics Host" rather than answers any of the questions above ;-)
fixes #9749