feat(language-service): log Angular compiler options (#40364)

This commit records the Angular compiler options in the log file to help
debugging.

PR Close #40364
This commit is contained in:
Keen Yee Liau 2021-01-08 10:40:06 -08:00 committed by atscott
parent 811cacc80c
commit 6a9e328432
1 changed files with 8 additions and 0 deletions

View File

@ -32,6 +32,7 @@ export class LanguageService {
constructor(project: ts.server.Project, private readonly tsLS: ts.LanguageService) { constructor(project: ts.server.Project, private readonly tsLS: ts.LanguageService) {
this.parseConfigHost = new LSParseConfigHost(project.projectService.host); this.parseConfigHost = new LSParseConfigHost(project.projectService.host);
this.options = parseNgCompilerOptions(project, this.parseConfigHost); this.options = parseNgCompilerOptions(project, this.parseConfigHost);
logCompilerOptions(project, this.options);
this.strategy = createTypeCheckingProgramStrategy(project); this.strategy = createTypeCheckingProgramStrategy(project);
this.adapter = new LanguageServiceAdapter(project); this.adapter = new LanguageServiceAdapter(project);
this.compilerFactory = new CompilerFactory(this.adapter, this.strategy, this.options); this.compilerFactory = new CompilerFactory(this.adapter, this.strategy, this.options);
@ -185,11 +186,18 @@ export class LanguageService {
project.log(`Config file changed: ${fileName}`); project.log(`Config file changed: ${fileName}`);
if (eventKind === ts.FileWatcherEventKind.Changed) { if (eventKind === ts.FileWatcherEventKind.Changed) {
this.options = parseNgCompilerOptions(project, this.parseConfigHost); this.options = parseNgCompilerOptions(project, this.parseConfigHost);
logCompilerOptions(project, this.options);
} }
}); });
} }
} }
function logCompilerOptions(project: ts.server.Project, options: CompilerOptions) {
const {logger} = project.projectService;
const projectName = project.getProjectName();
logger.info(`Angular compiler options for ${projectName}: ` + JSON.stringify(options, null, 2));
}
function parseNgCompilerOptions( function parseNgCompilerOptions(
project: ts.server.Project, host: ConfigurationHost): CompilerOptions { project: ts.server.Project, host: ConfigurationHost): CompilerOptions {
if (!(project instanceof ts.server.ConfiguredProject)) { if (!(project instanceof ts.server.ConfiguredProject)) {