Skip to content

use sys based host for formatting diagnostics#9750

Merged
vladima merged 1 commit into
masterfrom
fixFormatDiagnostics
Jul 15, 2016
Merged

use sys based host for formatting diagnostics#9750
vladima merged 1 commit into
masterfrom
fixFormatDiagnostics

Conversation

@vladima
Copy link
Copy Markdown
Contributor

@vladima vladima commented Jul 15, 2016

fixes #9749

@wycats
Copy link
Copy Markdown

wycats commented Jul 15, 2016

Heh. I just hit this!

Comment thread src/compiler/tsc.ts
getCanonicalFileName: createGetCanonicalFileName(sys.useCaseSensitiveFileNames)
};

let reportDiagnosticWorker = reportDiagnosticSimply;
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Comment thread src/compiler/program.ts
}

export function formatDiagnostics(diagnostics: Diagnostic[], host: CompilerHost): string {
export interface FormatDiagnosticsHost {
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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