Skip to content

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

Merged
merged 1 commit into from
Jul 15, 2016
Merged

Conversation

vladima
Copy link
Contributor

@vladima vladima commented Jul 15, 2016

fixes #9749

@wycats
Copy link

wycats commented Jul 15, 2016

Heh. I just hit this!

getCanonicalFileName: createGetCanonicalFileName(sys.useCaseSensitiveFileNames)
};

let reportDiagnosticWorker = reportDiagnosticSimply;
Copy link
Contributor

@yuit yuit Jul 15, 2016

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?

Copy link
Contributor Author

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

@yuit
Copy link
Contributor

yuit commented Jul 15, 2016

lgtm with small comment & question.

@vladima vladima merged commit 859bd1b into master Jul 15, 2016
@vladima vladima deleted the fixFormatDiagnostics branch July 15, 2016 19:33
vladima added a commit that referenced this pull request Jul 15, 2016
use sys based host for formatting diagnostics
vladima added a commit that referenced this pull request Jul 17, 2016
@@ -991,7 +991,13 @@ namespace ts {
return sortAndDeduplicateDiagnostics(diagnostics);
}

export function formatDiagnostics(diagnostics: Diagnostic[], host: CompilerHost): string {
export interface FormatDiagnosticsHost {
Copy link
Contributor

@mihailik mihailik Jul 18, 2016

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!

Copy link
Member

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.

Copy link
Contributor

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 ;-)

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"tsc --init" fails to complete successfuly
6 participants