refactor(compiler): tighten type of `TemplateParser._console` (#36741)
This property can actually be `null` when called from the language-service. This change allows us to remove the use of `!` to subvert the type system. PR Close #36741
This commit is contained in:
parent
7c8c41353b
commit
4172707346
|
@ -81,7 +81,7 @@ export class TemplateParser {
|
|||
constructor(
|
||||
private _config: CompilerConfig, private _reflector: CompileReflector,
|
||||
private _exprParser: Parser, private _schemaRegistry: ElementSchemaRegistry,
|
||||
private _htmlParser: HtmlParser, private _console: Console,
|
||||
private _htmlParser: HtmlParser, private _console: Console|null,
|
||||
public transforms: t.TemplateAstVisitor[]) {}
|
||||
|
||||
public get expressionParser() {
|
||||
|
@ -100,7 +100,7 @@ export class TemplateParser {
|
|||
const errors = result.errors!.filter(error => error.level === ParseErrorLevel.ERROR);
|
||||
|
||||
if (warnings.length > 0) {
|
||||
this._console.warn(`Template parse warnings:\n${warnings.join('\n')}`);
|
||||
this._console?.warn(`Template parse warnings:\n${warnings.join('\n')}`);
|
||||
}
|
||||
|
||||
if (errors.length > 0) {
|
||||
|
|
|
@ -516,8 +516,8 @@ export class TypeScriptServiceHost implements LanguageServiceHost {
|
|||
const parser = new TemplateParser(
|
||||
new CompilerConfig(), this.reflector, expressionParser, new DomElementSchemaRegistry(),
|
||||
htmlParser,
|
||||
null!, // console
|
||||
[] // tranforms
|
||||
null, // console
|
||||
[] // tranforms
|
||||
);
|
||||
const htmlResult = htmlParser.parse(template.source, fileName, {
|
||||
tokenizeExpansionForms: true,
|
||||
|
|
Loading…
Reference in New Issue