fix(compiler): don’t type check templates with skipTemplateCodegen
(#19909)
This change is needed to prevent users’ builds from breaking. If a user sets `fullTemlateTypeCheck` to true, we will continue to check the templates even when `skipTemplateCodegen` is true as well. Related to #19906 PR Close #19909
This commit is contained in:

committed by
Matias Niemelä

parent
f1108fea76
commit
18bce5987c
@ -426,6 +426,12 @@ export class TsCompilerAotCompilerTypeCheckHostAdapter implements ts.CompilerHos
|
||||
}
|
||||
|
||||
isSourceFile(filePath: string): boolean {
|
||||
// Don't generate any files nor typecheck them
|
||||
// if skipTemplateCodegen is set and fullTemplateTypeCheck is not yet set,
|
||||
// for backwards compatibility.
|
||||
if (this.options.skipTemplateCodegen && !this.options.fullTemplateTypeCheck) {
|
||||
return false;
|
||||
}
|
||||
// If we have a summary from a previous compilation,
|
||||
// treat the file never as a source file.
|
||||
if (this.librarySummaries.has(filePath)) {
|
||||
|
@ -181,11 +181,13 @@ function createVariableStatementForDeclarations(declarations: Declaration[]): ts
|
||||
/* modifiers */ undefined, ts.createVariableDeclarationList(varDecls, ts.NodeFlags.Const));
|
||||
}
|
||||
|
||||
export function getExpressionLoweringTransformFactory(requestsMap: RequestsMap):
|
||||
(context: ts.TransformationContext) => (sourceFile: ts.SourceFile) => ts.SourceFile {
|
||||
export function getExpressionLoweringTransformFactory(
|
||||
requestsMap: RequestsMap, program: ts.Program): (context: ts.TransformationContext) =>
|
||||
(sourceFile: ts.SourceFile) => ts.SourceFile {
|
||||
// Return the factory
|
||||
return (context: ts.TransformationContext) => (sourceFile: ts.SourceFile): ts.SourceFile => {
|
||||
const requests = requestsMap.getRequests(sourceFile);
|
||||
// We need to use the original SourceFile for reading metadata, and not the transformed one.
|
||||
const requests = requestsMap.getRequests(program.getSourceFile(sourceFile.fileName));
|
||||
if (requests && requests.size) {
|
||||
return transformSourceFile(sourceFile, requests, context);
|
||||
}
|
||||
|
@ -386,7 +386,7 @@ class AngularCompilerProgram implements Program {
|
||||
customTransformers?: CustomTransformers): ts.CustomTransformers {
|
||||
const beforeTs: ts.TransformerFactory<ts.SourceFile>[] = [];
|
||||
if (!this.options.disableExpressionLowering) {
|
||||
beforeTs.push(getExpressionLoweringTransformFactory(this.metadataCache));
|
||||
beforeTs.push(getExpressionLoweringTransformFactory(this.metadataCache, this.tsProgram));
|
||||
}
|
||||
beforeTs.push(getAngularEmitterTransformFactory(genFiles));
|
||||
if (customTransformers && customTransformers.beforeTs) {
|
||||
@ -754,7 +754,7 @@ export function createSrcToOutPathMapper(
|
||||
export function i18nExtract(
|
||||
formatName: string | null, outFile: string | null, host: ts.CompilerHost,
|
||||
options: CompilerOptions, bundle: MessageBundle): string[] {
|
||||
formatName = formatName || 'null';
|
||||
formatName = formatName || 'xlf';
|
||||
// Checks the format and returns the extension
|
||||
const ext = i18nGetExtension(formatName);
|
||||
const content = i18nSerialize(bundle, formatName, options);
|
||||
@ -788,7 +788,7 @@ export function i18nSerialize(
|
||||
}
|
||||
|
||||
export function i18nGetExtension(formatName: string): string {
|
||||
const format = (formatName || 'xlf').toLowerCase();
|
||||
const format = formatName.toLowerCase();
|
||||
|
||||
switch (format) {
|
||||
case 'xmb':
|
||||
|
Reference in New Issue
Block a user