From dea7f6f7eebbd53e4e447450453f004bc0f4dc3b Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 13 Mar 2026 11:30:53 +0100 Subject: [PATCH 01/10] refactor(core): update generated code signatures Updates the signatures of generated code to match what the compiler actually generates. --- packages/core/src/defer/instructions.ts | 2 +- packages/core/src/defer/interfaces.ts | 2 +- packages/core/src/render3/definition.ts | 4 ++-- packages/core/src/render3/features/providers_feature.ts | 2 +- .../core/src/render3/instructions/component_instance.ts | 2 +- packages/core/src/render3/instructions/di.ts | 2 +- packages/core/src/render3/instructions/projection.ts | 6 +++--- .../core/src/render3/instructions/queries_signals.ts | 9 ++++----- packages/core/src/render3/instructions/styling.ts | 7 +++++-- .../core/src/render3/interfaces/public_definitions.ts | 2 +- packages/core/src/render3/interfaces/sanitization.ts | 4 ++-- packages/core/src/render3/metadata.ts | 2 +- packages/core/src/sanitization/sanitization.ts | 6 +----- 13 files changed, 24 insertions(+), 26 deletions(-) diff --git a/packages/core/src/defer/instructions.ts b/packages/core/src/defer/instructions.ts index d31e23f540d7..727224f62951 100644 --- a/packages/core/src/defer/instructions.ts +++ b/packages/core/src/defer/instructions.ts @@ -131,7 +131,7 @@ export function ɵɵdefer( errorTmplIndex?: number | null, loadingConfigIndex?: number | null, placeholderConfigIndex?: number | null, - enableTimerScheduling?: typeof ɵɵdeferEnableTimerScheduling, + enableTimerScheduling?: typeof ɵɵdeferEnableTimerScheduling | null, flags?: TDeferDetailsFlags | null, ) { const lView = getLView(); diff --git a/packages/core/src/defer/interfaces.ts b/packages/core/src/defer/interfaces.ts index 4f9628644be9..441026476d07 100644 --- a/packages/core/src/defer/interfaces.ts +++ b/packages/core/src/defer/interfaces.ts @@ -26,7 +26,7 @@ export interface DehydratedDeferBlock { * Describes the shape of a function generated by the compiler * to download dependencies that can be defer-loaded. */ -export type DependencyResolverFn = () => Array>; +export type DependencyResolverFn = () => Array | DependencyType>; /** * Defines types of defer block triggers. diff --git a/packages/core/src/render3/definition.ts b/packages/core/src/render3/definition.ts index b90a8aa3bacb..37e8c6f35cff 100644 --- a/packages/core/src/render3/definition.ts +++ b/packages/core/src/render3/definition.ts @@ -118,7 +118,7 @@ interface DirectiveDefinition { type: Type; /** The selectors that will be used to match nodes to this directive. */ - selectors?: CssSelectorList; + selectors?: (string | number)[][]; /** * A map of input names. @@ -270,7 +270,7 @@ interface ComponentDefinition extends Omit, 'features' * Constants for the nodes in the component's view. * Includes attribute arrays, local definition arrays etc. */ - consts?: TConstantsOrFactory; + consts?: any[] | (() => any[]); /** * An array of `ngContent[selector]` values that were found in the template. diff --git a/packages/core/src/render3/features/providers_feature.ts b/packages/core/src/render3/features/providers_feature.ts index b1c104e00a00..3ded88786adf 100644 --- a/packages/core/src/render3/features/providers_feature.ts +++ b/packages/core/src/render3/features/providers_feature.ts @@ -41,7 +41,7 @@ import {DirectiveDef} from '../interfaces/definition'; * * @codeGenApi */ -export function ɵɵProvidersFeature(providers: Provider[], viewProviders: Provider[]) { +export function ɵɵProvidersFeature(providers: Provider[], viewProviders?: Provider[]) { return (definition: DirectiveDef) => { definition.providersResolver = (def, processProvidersFn) => providersResolver(def, processProvidersFn ? processProvidersFn(providers) : providers, false); diff --git a/packages/core/src/render3/instructions/component_instance.ts b/packages/core/src/render3/instructions/component_instance.ts index ce5eef09a3ed..7f9f898fafe4 100644 --- a/packages/core/src/render3/instructions/component_instance.ts +++ b/packages/core/src/render3/instructions/component_instance.ts @@ -17,7 +17,7 @@ import {getLView} from '../state'; * * @codeGenApi */ -export function ɵɵcomponentInstance(): unknown { +export function ɵɵcomponentInstance(): any { const instance = getLView()[DECLARATION_COMPONENT_VIEW][CONTEXT]; ngDevMode && assertDefined(instance, 'Expected component instance to be defined'); return instance; diff --git a/packages/core/src/render3/instructions/di.ts b/packages/core/src/render3/instructions/di.ts index a9df9d610dc2..e46a2d1bb56a 100644 --- a/packages/core/src/render3/instructions/di.ts +++ b/packages/core/src/render3/instructions/di.ts @@ -41,7 +41,7 @@ import {getCurrentTNode, getLView} from '../state'; * @codeGenApi */ export function ɵɵdirectiveInject(token: ProviderToken): T; -export function ɵɵdirectiveInject(token: ProviderToken, flags: InternalInjectFlags): T; +export function ɵɵdirectiveInject(token: ProviderToken, flags: number): T; export function ɵɵdirectiveInject( token: ProviderToken, flags = InternalInjectFlags.Default, diff --git a/packages/core/src/render3/instructions/projection.ts b/packages/core/src/render3/instructions/projection.ts index 7e2630c05ec4..90e9c0b0b466 100644 --- a/packages/core/src/render3/instructions/projection.ts +++ b/packages/core/src/render3/instructions/projection.ts @@ -93,7 +93,7 @@ export function matchingProjectionSlotIndex( * * @codeGenApi */ -export function ɵɵprojectionDef(projectionSlots?: ProjectionSlots): void { +export function ɵɵprojectionDef(projectionSlots?: (string | (string | number)[][])[]): void { const componentNode = getLView()[DECLARATION_COMPONENT_VIEW][T_HOST] as TElementNode; if (!componentNode.projection) { @@ -112,7 +112,7 @@ export function ɵɵprojectionDef(projectionSlots?: ProjectionSlots): void { // Do not project let declarations so they don't occupy a slot. if (componentChild.type !== TNodeType.LetDeclaration) { const slotIndex = projectionSlots - ? matchingProjectionSlotIndex(componentChild, projectionSlots) + ? matchingProjectionSlotIndex(componentChild, projectionSlots as ProjectionSlots) : 0; if (slotIndex !== null) { @@ -149,7 +149,7 @@ export function ɵɵprojectionDef(projectionSlots?: ProjectionSlots): void { export function ɵɵprojection( nodeIndex: number, selectorIndex: number = 0, - attrs?: TAttributes, + attrs?: TAttributes | null, fallbackTemplateFn?: ComponentTemplate, fallbackDecls?: number, fallbackVars?: number, diff --git a/packages/core/src/render3/instructions/queries_signals.ts b/packages/core/src/render3/instructions/queries_signals.ts index 083a1bc61546..7a9946620d6e 100644 --- a/packages/core/src/render3/instructions/queries_signals.ts +++ b/packages/core/src/render3/instructions/queries_signals.ts @@ -7,7 +7,6 @@ */ import {ProviderToken} from '../../di/provider_token'; -import {QueryFlags} from '../interfaces/query'; import {createContentQuery, createViewQuery} from '../queries/query'; import {bindQueryToSignal} from '../queries/query_reactive'; import {Signal} from '../reactivity/api'; @@ -27,8 +26,8 @@ import {getCurrentQueryIndex, setCurrentQueryIndex} from '../state'; export function ɵɵcontentQuerySignal( directiveIndex: number, target: Signal, - predicate: ProviderToken | string[], - flags: QueryFlags, + predicate: ProviderToken | string[] | string, + flags: number, read?: any, ): typeof ɵɵcontentQuerySignal { bindQueryToSignal(target, createContentQuery(directiveIndex, predicate, flags, read)); @@ -48,8 +47,8 @@ export function ɵɵcontentQuerySignal( */ export function ɵɵviewQuerySignal( target: Signal, - predicate: ProviderToken | string[], - flags: QueryFlags, + predicate: ProviderToken | string[] | string, + flags: number, read?: ProviderToken, ): typeof ɵɵviewQuerySignal { bindQueryToSignal(target, createViewQuery(predicate, flags, read)); diff --git a/packages/core/src/render3/instructions/styling.ts b/packages/core/src/render3/instructions/styling.ts index be96a0dde15a..a46a5a73dc0e 100644 --- a/packages/core/src/render3/instructions/styling.ts +++ b/packages/core/src/render3/instructions/styling.ts @@ -125,7 +125,9 @@ export function ɵɵclassProp( * * @codeGenApi */ -export function ɵɵstyleMap(styles: {[styleName: string]: any} | string | undefined | null): void { +export function ɵɵstyleMap( + styles: {[styleName: string]: any} | string | undefined | null | NO_CHANGE, +): void { checkStylingMap(styleKeyValueArraySet, styleStringParser, styles, false); } @@ -169,7 +171,8 @@ export function ɵɵclassMap( | string[] | Set | undefined - | null, + | null + | NO_CHANGE, ): void { checkStylingMap(classKeyValueArraySet, classStringParser, classes, true); } diff --git a/packages/core/src/render3/interfaces/public_definitions.ts b/packages/core/src/render3/interfaces/public_definitions.ts index e7ef50f5ddfa..d001916d8bd4 100644 --- a/packages/core/src/render3/interfaces/public_definitions.ts +++ b/packages/core/src/render3/interfaces/public_definitions.ts @@ -66,7 +66,7 @@ export type ɵɵNgModuleDeclaration = unknown */ export type ɵɵPipeDeclaration< T, - Name extends string, + Name extends string | null, // Optional as this was added in Angular v14. All pre-existing directives // are not standalone. IsStandalone extends boolean = false, diff --git a/packages/core/src/render3/interfaces/sanitization.ts b/packages/core/src/render3/interfaces/sanitization.ts index eab5ba4928df..c1a10382e054 100644 --- a/packages/core/src/render3/interfaces/sanitization.ts +++ b/packages/core/src/render3/interfaces/sanitization.ts @@ -13,6 +13,6 @@ import {TrustedHTML, TrustedScript, TrustedScriptURL} from '../../util/security/ */ export type SanitizerFn = ( value: any, - tagName?: string, - propName?: string, + tagName: string, + propName: string, ) => string | TrustedHTML | TrustedScript | TrustedScriptURL; diff --git a/packages/core/src/render3/metadata.ts b/packages/core/src/render3/metadata.ts index b1c8416aa185..3203b168fd81 100644 --- a/packages/core/src/render3/metadata.ts +++ b/packages/core/src/render3/metadata.ts @@ -70,7 +70,7 @@ export function setClassMetadataAsync( * being tree-shaken away during production builds. */ export function setClassMetadata( - type: Type, + type: any, decorators: any[] | null, ctorParameters: (() => any[]) | null, propDecorators: {[field: string]: any} | null, diff --git a/packages/core/src/sanitization/sanitization.ts b/packages/core/src/sanitization/sanitization.ts index 0b2c65ce1679..cd4cefad1c99 100644 --- a/packages/core/src/sanitization/sanitization.ts +++ b/packages/core/src/sanitization/sanitization.ts @@ -305,11 +305,7 @@ const SECURITY_SENSITIVE_ELEMENTS: Readonly>> * @param tagName The name of the tag. * @param attributeName The name of the attribute. */ -export function ɵɵvalidateAttribute( - value: unknown, - tagName: string, - attributeName: string, -): unknown { +export function ɵɵvalidateAttribute(value: T, tagName: string, attributeName: string): T { const lowerCaseTagName = tagName.toLowerCase(); const lowerCaseAttrName = attributeName.toLowerCase(); if (!SECURITY_SENSITIVE_ELEMENTS[lowerCaseTagName]?.has(lowerCaseAttrName)) { From 45d382ee78f5da3fe1f302ad5714894913a0eee7 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 13 Mar 2026 11:32:16 +0100 Subject: [PATCH 02/10] fix(compiler): stop generating unused field Fixes that the compiler was generating an `attrs` field on the definition which isn't used anywhere. --- .../compiler/src/render3/view/compiler.ts | 23 ------------------- 1 file changed, 23 deletions(-) diff --git a/packages/compiler/src/render3/view/compiler.ts b/packages/compiler/src/render3/view/compiler.ts index 77ac761b57ac..5316dce25a4c 100644 --- a/packages/compiler/src/render3/view/compiler.ts +++ b/packages/compiler/src/render3/view/compiler.ts @@ -8,7 +8,6 @@ import {ConstantPool} from '../../constant_pool'; import * as core from '../../core'; -import {CssSelector} from '../../directive_matching'; import * as o from '../../output/output_ast'; import {ParseError, ParseSourceSpan} from '../../parse_util'; import {ShadowCss} from '../../shadow_css'; @@ -194,28 +193,6 @@ export function compileComponentFromMetadata( const definitionMap = baseDirectiveFields(meta, constantPool, bindingParser); addFeatures(definitionMap, meta); - const selector = meta.selector && CssSelector.parse(meta.selector); - const firstSelector = selector && selector[0]; - - // e.g. `attr: ["class", ".my.app"]` - // This is optional an only included if the first selector of a component specifies attributes. - if (firstSelector) { - const selectorAttributes = firstSelector.getAttrs(); - if (selectorAttributes.length) { - definitionMap.set( - 'attrs', - constantPool.getConstLiteral( - o.literalArr( - selectorAttributes.map((value) => - value != null ? o.literal(value) : o.literal(undefined), - ), - ), - /* forceShared */ true, - ), - ); - } - } - // e.g. `template: function MyComponent_Template(_ctx, _cm) {...}` const templateTypeName = meta.name; From 30a6493d29a84cc127155aeb11eaed9132535d40 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 13 Mar 2026 11:33:25 +0100 Subject: [PATCH 03/10] fix(compiler-cli): transform dropping exclamationToken from properties Fixes that the Ivy transform was dropping the `exclamationToken` from properties. --- packages/compiler-cli/src/ngtsc/transform/src/transform.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/compiler-cli/src/ngtsc/transform/src/transform.ts b/packages/compiler-cli/src/ngtsc/transform/src/transform.ts index 2df5130082e4..c7a4ee862cfd 100644 --- a/packages/compiler-cli/src/ngtsc/transform/src/transform.ts +++ b/packages/compiler-cli/src/ngtsc/transform/src/transform.ts @@ -349,7 +349,7 @@ class IvyTransformationVisitor extends Visitor { node, combinedModifiers, node.name, - node.questionToken, + node.questionToken || node.exclamationToken, node.type, node.initializer, ) as T & ts.PropertyDeclaration; From d9a02f37fb2f56436bb71694eb670e608b8f54c9 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 13 Mar 2026 11:35:46 +0100 Subject: [PATCH 04/10] refactor(compiler): allow leading comments on expressions Updates the output AST to allow leading comments to be attached to expression nodes. --- .../src/ngtsc/translator/src/translator.ts | 224 ++++++++++++------ .../compiler/src/output/abstract_emitter.ts | 38 ++- packages/compiler/src/output/output_ast.ts | 101 +++++--- 3 files changed, 249 insertions(+), 114 deletions(-) diff --git a/packages/compiler-cli/src/ngtsc/translator/src/translator.ts b/packages/compiler-cli/src/ngtsc/translator/src/translator.ts index 60a07cdb8cf1..c18b720aa669 100644 --- a/packages/compiler-cli/src/ngtsc/translator/src/translator.ts +++ b/packages/compiler-cli/src/ngtsc/translator/src/translator.ts @@ -153,52 +153,70 @@ export class ExpressionTranslatorVisitor visitReadVarExpr(ast: o.ReadVarExpr, _context: Context): TExpression { const identifier = this.factory.createIdentifier(ast.name!); this.setSourceMapRange(identifier, ast.sourceSpan); - return identifier; + return this.attachComments(identifier, ast.leadingComments); } visitInvokeFunctionExpr(ast: o.InvokeFunctionExpr, context: Context): TExpression { - return this.setSourceMapRange( - this.factory.createCallExpression( - ast.fn.visitExpression(this, context), - ast.args.map((arg) => arg.visitExpression(this, context)), - ast.pure, + return this.attachComments( + this.setSourceMapRange( + this.factory.createCallExpression( + ast.fn.visitExpression(this, context), + ast.args.map((arg) => arg.visitExpression(this, context)), + ast.pure, + ), + ast.sourceSpan, ), - ast.sourceSpan, + ast.leadingComments, ); } visitTaggedTemplateLiteralExpr(ast: o.TaggedTemplateLiteralExpr, context: Context): TExpression { - return this.setSourceMapRange( - this.createTaggedTemplateExpression( - ast.tag.visitExpression(this, context), - this.getTemplateLiteralFromAst(ast.template, context), + return this.attachComments( + this.setSourceMapRange( + this.createTaggedTemplateExpression( + ast.tag.visitExpression(this, context), + this.getTemplateLiteralFromAst(ast.template, context), + ), + ast.sourceSpan, ), - ast.sourceSpan, + ast.leadingComments, ); } visitTemplateLiteralExpr(ast: o.TemplateLiteralExpr, context: Context): TExpression { - return this.setSourceMapRange( - this.factory.createTemplateLiteral(this.getTemplateLiteralFromAst(ast, context)), - ast.sourceSpan, + return this.attachComments( + this.setSourceMapRange( + this.factory.createTemplateLiteral(this.getTemplateLiteralFromAst(ast, context)), + ast.sourceSpan, + ), + ast.leadingComments, ); } visitInstantiateExpr(ast: o.InstantiateExpr, context: Context): TExpression { - return this.factory.createNewExpression( - ast.classExpr.visitExpression(this, context), - ast.args.map((arg) => arg.visitExpression(this, context)), + return this.attachComments( + this.factory.createNewExpression( + ast.classExpr.visitExpression(this, context), + ast.args.map((arg) => arg.visitExpression(this, context)), + ), + ast.leadingComments, ); } visitLiteralExpr(ast: o.LiteralExpr, _context: Context): TExpression { - return this.setSourceMapRange(this.factory.createLiteral(ast.value), ast.sourceSpan); + return this.attachComments( + this.setSourceMapRange(this.factory.createLiteral(ast.value), ast.sourceSpan), + ast.leadingComments, + ); } visitRegularExpressionLiteral(ast: o.RegularExpressionLiteralExpr, context: any) { - return this.setSourceMapRange( - this.factory.createRegularExpressionLiteral(ast.body, ast.flags), - ast.sourceSpan, + return this.attachComments( + this.setSourceMapRange( + this.factory.createRegularExpressionLiteral(ast.body, ast.flags), + ast.sourceSpan, + ), + ast.leadingComments, ); } @@ -228,9 +246,12 @@ export class ExpressionTranslatorVisitor } const localizeTag = this.factory.createIdentifier('$localize'); - return this.setSourceMapRange( - this.createTaggedTemplateExpression(localizeTag, {elements, expressions}), - ast.sourceSpan, + return this.attachComments( + this.setSourceMapRange( + this.createTaggedTemplateExpression(localizeTag, {elements, expressions}), + ast.sourceSpan, + ), + ast.leadingComments, ); } @@ -342,36 +363,40 @@ export class ExpressionTranslatorVisitor } visitExternalExpr(ast: o.ExternalExpr, _context: Context): TExpression { + let result: TExpression; if (ast.value.name === null) { if (ast.value.moduleName === null) { throw new Error('Invalid import without name nor moduleName'); } - return this.imports.addImport({ + result = this.imports.addImport({ exportModuleSpecifier: ast.value.moduleName, exportSymbolName: null, requestedFile: this.contextFile, }); - } - // If a moduleName is specified, this is a normal import. If there's no module name, it's a - // reference to a global/ambient symbol. - if (ast.value.moduleName !== null) { + } else if (ast.value.moduleName !== null) { + // If a moduleName is specified, this is a normal import. If there's no module name, it's a + // reference to a global/ambient symbol. // This is a normal import. Find the imported module. - return this.imports.addImport({ + result = this.imports.addImport({ exportModuleSpecifier: ast.value.moduleName, exportSymbolName: ast.value.name, requestedFile: this.contextFile, }); } else { // The symbol is ambient, so just reference it. - return this.factory.createIdentifier(ast.value.name); + result = this.factory.createIdentifier(ast.value.name); } + return this.attachComments(result, ast.leadingComments); } visitConditionalExpr(ast: o.ConditionalExpr, context: Context): TExpression { - return this.factory.createConditional( - ast.condition.visitExpression(this, context), - ast.trueCase.visitExpression(this, context), - ast.falseCase!.visitExpression(this, context), + return this.attachComments( + this.factory.createConditional( + ast.condition.visitExpression(this, context), + ast.trueCase.visitExpression(this, context), + ast.falseCase!.visitExpression(this, context), + ), + ast.leadingComments, ); } @@ -384,27 +409,39 @@ export class ExpressionTranslatorVisitor this.factory.attachComments(urlExpression, [o.leadingComment(ast.urlComment, true)]); } - return this.factory.createDynamicImport(urlExpression); + return this.attachComments( + this.factory.createDynamicImport(urlExpression), + ast.leadingComments, + ); } visitNotExpr(ast: o.NotExpr, context: Context): TExpression { - return this.factory.createUnaryExpression('!', ast.condition.visitExpression(this, context)); + return this.attachComments( + this.factory.createUnaryExpression('!', ast.condition.visitExpression(this, context)), + ast.leadingComments, + ); } visitFunctionExpr(ast: o.FunctionExpr, context: Context): TExpression { - return this.factory.createFunctionExpression( - ast.name ?? null, - this.translateParams(ast.params, context), - this.factory.createBlock(this.visitStatements(ast.statements, context)), + return this.attachComments( + this.factory.createFunctionExpression( + ast.name ?? null, + this.translateParams(ast.params, context), + this.factory.createBlock(this.visitStatements(ast.statements, context)), + ), + ast.leadingComments, ); } visitArrowFunctionExpr(ast: o.ArrowFunctionExpr, context: any) { - return this.factory.createArrowFunctionExpression( - this.translateParams(ast.params, context), - Array.isArray(ast.body) - ? this.factory.createBlock(this.visitStatements(ast.body, context)) - : ast.body.visitExpression(this, context), + return this.attachComments( + this.factory.createArrowFunctionExpression( + this.translateParams(ast.params, context), + Array.isArray(ast.body) + ? this.factory.createBlock(this.visitStatements(ast.body, context)) + : ast.body.visitExpression(this, context), + ), + ast.leadingComments, ); } @@ -416,36 +453,51 @@ export class ExpressionTranslatorVisitor const operator = BINARY_OPERATORS.get(ast.operator)!; if (ast.isAssignment()) { - return this.factory.createAssignment( - ast.lhs.visitExpression(this, context), - operator, - ast.rhs.visitExpression(this, context), + return this.attachComments( + this.factory.createAssignment( + ast.lhs.visitExpression(this, context), + operator, + ast.rhs.visitExpression(this, context), + ), + ast.leadingComments, ); } - return this.factory.createBinaryExpression( - ast.lhs.visitExpression(this, context), - operator, - ast.rhs.visitExpression(this, context), + return this.attachComments( + this.factory.createBinaryExpression( + ast.lhs.visitExpression(this, context), + operator, + ast.rhs.visitExpression(this, context), + ), + ast.leadingComments, ); } visitReadPropExpr(ast: o.ReadPropExpr, context: Context): TExpression { - return this.factory.createPropertyAccess(ast.receiver.visitExpression(this, context), ast.name); + return this.attachComments( + this.factory.createPropertyAccess(ast.receiver.visitExpression(this, context), ast.name), + ast.leadingComments, + ); } visitReadKeyExpr(ast: o.ReadKeyExpr, context: Context): TExpression { - return this.factory.createElementAccess( - ast.receiver.visitExpression(this, context), - ast.index.visitExpression(this, context), + return this.attachComments( + this.factory.createElementAccess( + ast.receiver.visitExpression(this, context), + ast.index.visitExpression(this, context), + ), + ast.leadingComments, ); } visitLiteralArrayExpr(ast: o.LiteralArrayExpr, context: Context): TExpression { - return this.factory.createArrayLiteral( - ast.entries.map((expr) => - this.setSourceMapRange(expr.visitExpression(this, context), ast.sourceSpan), + return this.attachComments( + this.factory.createArrayLiteral( + ast.entries.map((expr) => + this.setSourceMapRange(expr.visitExpression(this, context), ast.sourceSpan), + ), ), + ast.leadingComments, ); } @@ -463,7 +515,10 @@ export class ExpressionTranslatorVisitor expression: entry.expression.visitExpression(this, context), } satisfies ObjectLiteralSpread); }); - return this.setSourceMapRange(this.factory.createObjectLiteral(properties), ast.sourceSpan); + return this.attachComments( + this.setSourceMapRange(this.factory.createObjectLiteral(properties), ast.sourceSpan), + ast.leadingComments, + ); } visitCommaExpr(ast: o.CommaExpr, context: Context): never { @@ -476,35 +531,50 @@ export class ExpressionTranslatorVisitor visitSpreadElementExpr(ast: o.outputAst.SpreadElementExpr, context: any): TExpression { const expression = ast.expression.visitExpression(this, context); - return this.setSourceMapRange(this.factory.createSpreadElement(expression), ast.sourceSpan); + return this.attachComments( + this.setSourceMapRange(this.factory.createSpreadElement(expression), ast.sourceSpan), + ast.leadingComments, + ); } visitWrappedNodeExpr(ast: o.WrappedNodeExpr, _context: Context): any { this.recordWrappedNode(ast); - return ast.node; + return this.attachComments(ast.node, ast.leadingComments); } visitTypeofExpr(ast: o.TypeofExpr, context: Context): TExpression { - return this.factory.createTypeOfExpression(ast.expr.visitExpression(this, context)); + return this.attachComments( + this.factory.createTypeOfExpression(ast.expr.visitExpression(this, context)), + ast.leadingComments, + ); } visitVoidExpr(ast: o.VoidExpr, context: Context): TExpression { - return this.factory.createVoidExpression(ast.expr.visitExpression(this, context)); + return this.attachComments( + this.factory.createVoidExpression(ast.expr.visitExpression(this, context)), + ast.leadingComments, + ); } visitUnaryOperatorExpr(ast: o.UnaryOperatorExpr, context: Context): TExpression { if (!UNARY_OPERATORS.has(ast.operator)) { throw new Error(`Unknown unary operator: ${o.UnaryOperator[ast.operator]}`); } - return this.factory.createUnaryExpression( - UNARY_OPERATORS.get(ast.operator)!, - ast.expr.visitExpression(this, context), + return this.attachComments( + this.factory.createUnaryExpression( + UNARY_OPERATORS.get(ast.operator)!, + ast.expr.visitExpression(this, context), + ), + ast.leadingComments, ); } visitParenthesizedExpr(ast: o.ParenthesizedExpr, context: any) { const result = ast.expr.visitExpression(this, context); - return this.factory.createParenthesizedExpression(result); + return this.attachComments( + this.factory.createParenthesizedExpression(result), + ast.leadingComments, + ); } private visitStatements(statements: o.Statement[], context: Context): TStatement[] { @@ -520,14 +590,14 @@ export class ExpressionTranslatorVisitor return this.factory.setSourceMapRange(ast, createRange(span)); } - private attachComments( - statement: TStatement, + private attachComments( + node: T, leadingComments: o.LeadingComment[] | undefined, - ): TStatement { - if (leadingComments !== undefined) { - this.factory.attachComments(statement, leadingComments); + ): T { + if (leadingComments !== undefined && leadingComments.length > 0) { + this.factory.attachComments(node, leadingComments); } - return statement; + return node; } private getTemplateLiteralFromAst( diff --git a/packages/compiler/src/output/abstract_emitter.ts b/packages/compiler/src/output/abstract_emitter.ts index adcff8205d66..fb200264e321 100644 --- a/packages/compiler/src/output/abstract_emitter.ts +++ b/packages/compiler/src/output/abstract_emitter.ts @@ -216,19 +216,22 @@ export abstract class AbstractEmitterVisitor implements o.StatementVisitor, o.Ex constructor(private _escapeDollarInStrings: boolean) {} - protected printLeadingComments(stmt: o.Statement, ctx: EmitterVisitorContext): void { - if (stmt.leadingComments === undefined) { + protected printLeadingComments( + node: o.Expression | o.Statement, + ctx: EmitterVisitorContext, + ): void { + if (node.leadingComments === undefined) { return; } - for (const comment of stmt.leadingComments) { + for (const comment of node.leadingComments) { if (comment instanceof o.JSDocComment) { - ctx.print(stmt, `/*${comment.toString()}*/`, comment.trailingNewline); + ctx.print(node, `/*${comment.toString()}*/`, comment.trailingNewline); } else { if (comment.multiline) { - ctx.print(stmt, `/* ${comment.text} */`, comment.trailingNewline); + ctx.print(node, `/* ${comment.text} */`, comment.trailingNewline); } else { comment.text.split('\n').forEach((line) => { - ctx.println(stmt, `// ${line}`); + ctx.println(node, `// ${line}`); }); } } @@ -282,6 +285,7 @@ export abstract class AbstractEmitterVisitor implements o.StatementVisitor, o.Ex abstract visitDeclareVarStmt(stmt: o.DeclareVarStmt, ctx: EmitterVisitorContext): any; visitInvokeFunctionExpr(expr: o.InvokeFunctionExpr, ctx: EmitterVisitorContext): any { + this.printLeadingComments(expr, ctx); const shouldParenthesize = expr.fn instanceof o.ArrowFunctionExpr; if (shouldParenthesize) { @@ -300,11 +304,13 @@ export abstract class AbstractEmitterVisitor implements o.StatementVisitor, o.Ex expr: o.TaggedTemplateLiteralExpr, ctx: EmitterVisitorContext, ): any { + this.printLeadingComments(expr, ctx); expr.tag.visitExpression(this, ctx); expr.template.visitExpression(this, ctx); return null; } visitTemplateLiteralExpr(expr: o.TemplateLiteralExpr, ctx: EmitterVisitorContext) { + this.printLeadingComments(expr, ctx); ctx.print(expr, '`'); for (let i = 0; i < expr.elements.length; i++) { expr.elements[i].visitExpression(this, ctx); @@ -318,24 +324,29 @@ export abstract class AbstractEmitterVisitor implements o.StatementVisitor, o.Ex ctx.print(expr, '`'); } visitTemplateLiteralElementExpr(expr: o.TemplateLiteralElementExpr, ctx: EmitterVisitorContext) { + this.printLeadingComments(expr, ctx); ctx.print(expr, expr.rawText); } visitWrappedNodeExpr(ast: o.WrappedNodeExpr, ctx: EmitterVisitorContext): any { throw new Error('Abstract emitter cannot visit WrappedNodeExpr.'); } visitTypeofExpr(expr: o.TypeofExpr, ctx: EmitterVisitorContext): any { + this.printLeadingComments(expr, ctx); ctx.print(expr, 'typeof '); expr.expr.visitExpression(this, ctx); } visitVoidExpr(expr: o.VoidExpr, ctx: EmitterVisitorContext): any { + this.printLeadingComments(expr, ctx); ctx.print(expr, 'void '); expr.expr.visitExpression(this, ctx); } visitReadVarExpr(ast: o.ReadVarExpr, ctx: EmitterVisitorContext): any { + this.printLeadingComments(ast, ctx); ctx.print(ast, ast.name); return null; } visitInstantiateExpr(ast: o.InstantiateExpr, ctx: EmitterVisitorContext): any { + this.printLeadingComments(ast, ctx); ctx.print(ast, `new `); ast.classExpr.visitExpression(this, ctx); ctx.print(ast, `(`); @@ -345,6 +356,7 @@ export abstract class AbstractEmitterVisitor implements o.StatementVisitor, o.Ex } visitLiteralExpr(ast: o.LiteralExpr, ctx: EmitterVisitorContext): any { + this.printLeadingComments(ast, ctx); const value = ast.value; if (typeof value === 'string') { ctx.print(ast, escapeIdentifier(value, this._escapeDollarInStrings)); @@ -358,11 +370,13 @@ export abstract class AbstractEmitterVisitor implements o.StatementVisitor, o.Ex ast: o.RegularExpressionLiteralExpr, ctx: EmitterVisitorContext, ): any { + this.printLeadingComments(ast, ctx); ctx.print(ast, `/${ast.body}/${ast.flags || ''}`); return null; } visitLocalizedString(ast: o.LocalizedString, ctx: EmitterVisitorContext): any { + this.printLeadingComments(ast, ctx); const head = ast.serializeI18nHead(); ctx.print(ast, '$localize `' + head.raw); for (let i = 1; i < ast.messageParts.length; i++) { @@ -377,6 +391,7 @@ export abstract class AbstractEmitterVisitor implements o.StatementVisitor, o.Ex abstract visitExternalExpr(ast: o.ExternalExpr, ctx: EmitterVisitorContext): any; visitConditionalExpr(ast: o.ConditionalExpr, ctx: EmitterVisitorContext): any { + this.printLeadingComments(ast, ctx); ctx.print(ast, `(`); ast.condition.visitExpression(this, ctx); ctx.print(ast, '? '); @@ -388,10 +403,12 @@ export abstract class AbstractEmitterVisitor implements o.StatementVisitor, o.Ex } visitDynamicImportExpr(ast: o.DynamicImportExpr, ctx: EmitterVisitorContext) { + this.printLeadingComments(ast, ctx); ctx.print(ast, `import(${ast.url})`); } visitNotExpr(ast: o.NotExpr, ctx: EmitterVisitorContext): any { + this.printLeadingComments(ast, ctx); ctx.print(ast, '!'); ast.condition.visitExpression(this, ctx); return null; @@ -401,6 +418,7 @@ export abstract class AbstractEmitterVisitor implements o.StatementVisitor, o.Ex abstract visitDeclareFunctionStmt(stmt: o.DeclareFunctionStmt, context: any): any; visitUnaryOperatorExpr(ast: o.UnaryOperatorExpr, ctx: EmitterVisitorContext): any { + this.printLeadingComments(ast, ctx); let opStr: string; switch (ast.operator) { case o.UnaryOperator.Plus: @@ -421,6 +439,7 @@ export abstract class AbstractEmitterVisitor implements o.StatementVisitor, o.Ex } visitBinaryOperatorExpr(ast: o.BinaryOperatorExpr, ctx: EmitterVisitorContext): any { + this.printLeadingComments(ast, ctx); const operator = BINARY_OPERATORS.get(ast.operator); if (!operator) { throw new Error(`Unknown operator ${ast.operator}`); @@ -435,12 +454,14 @@ export abstract class AbstractEmitterVisitor implements o.StatementVisitor, o.Ex } visitReadPropExpr(ast: o.ReadPropExpr, ctx: EmitterVisitorContext): any { + this.printLeadingComments(ast, ctx); ast.receiver.visitExpression(this, ctx); ctx.print(ast, `.`); ctx.print(ast, ast.name); return null; } visitReadKeyExpr(ast: o.ReadKeyExpr, ctx: EmitterVisitorContext): any { + this.printLeadingComments(ast, ctx); ast.receiver.visitExpression(this, ctx); ctx.print(ast, `[`); ast.index.visitExpression(this, ctx); @@ -448,12 +469,14 @@ export abstract class AbstractEmitterVisitor implements o.StatementVisitor, o.Ex return null; } visitLiteralArrayExpr(ast: o.LiteralArrayExpr, ctx: EmitterVisitorContext): any { + this.printLeadingComments(ast, ctx); ctx.print(ast, `[`); this.visitAllExpressions(ast.entries, ctx, ','); ctx.print(ast, `]`); return null; } visitLiteralMapExpr(ast: o.LiteralMapExpr, ctx: EmitterVisitorContext): any { + this.printLeadingComments(ast, ctx); ctx.print(ast, `{`); this.visitAllObjects( (entry) => { @@ -476,18 +499,21 @@ export abstract class AbstractEmitterVisitor implements o.StatementVisitor, o.Ex return null; } visitCommaExpr(ast: o.CommaExpr, ctx: EmitterVisitorContext): any { + this.printLeadingComments(ast, ctx); ctx.print(ast, '('); this.visitAllExpressions(ast.parts, ctx, ','); ctx.print(ast, ')'); return null; } visitParenthesizedExpr(ast: o.ParenthesizedExpr, ctx: EmitterVisitorContext): any { + this.printLeadingComments(ast, ctx); // We parenthesize everything regardless of an explicit ParenthesizedExpr, so we can just visit // the inner expression. // TODO: Do we *need* to parenthesize everything? ast.expr.visitExpression(this, ctx); } visitSpreadElementExpr(ast: o.SpreadElementExpr, ctx: EmitterVisitorContext) { + this.printLeadingComments(ast, ctx); ctx.print(ast, '...'); ast.expression.visitExpression(this, ctx); } diff --git a/packages/compiler/src/output/output_ast.ts b/packages/compiler/src/output/output_ast.ts index cf12cc811ffe..55199be4d0da 100644 --- a/packages/compiler/src/output/output_ast.ts +++ b/packages/compiler/src/output/output_ast.ts @@ -195,7 +195,11 @@ export abstract class Expression { public type: Type | null; public sourceSpan: ParseSourceSpan | null; - constructor(type: Type | null | undefined, sourceSpan?: ParseSourceSpan | null) { + constructor( + type: Type | null | undefined, + sourceSpan?: ParseSourceSpan | null, + public leadingComments?: LeadingComment[], + ) { this.type = type || null; this.sourceSpan = sourceSpan || null; } @@ -227,14 +231,16 @@ export abstract class Expression { params: Expression[], sourceSpan?: ParseSourceSpan | null, pure?: boolean, + leadingComments?: LeadingComment[], ): InvokeFunctionExpr { - return new InvokeFunctionExpr(this, params, null, sourceSpan, pure); + return new InvokeFunctionExpr(this, params, null, sourceSpan, pure, leadingComments); } instantiate( params: Expression[], type?: Type | null, sourceSpan?: ParseSourceSpan | null, + leadingComments?: LeadingComment[], ): InstantiateExpr { return new InstantiateExpr(this, params, type, sourceSpan); } @@ -243,6 +249,7 @@ export abstract class Expression { trueCase: Expression, falseCase: Expression | null = null, sourceSpan?: ParseSourceSpan | null, + leadingComments?: LeadingComment[], ): ConditionalExpr { return new ConditionalExpr(this, trueCase, falseCase, null, sourceSpan); } @@ -320,8 +327,9 @@ export class ReadVarExpr extends Expression { public name: string, type?: Type | null, sourceSpan?: ParseSourceSpan | null, + leadingComments?: LeadingComment[], ) { - super(type, sourceSpan); + super(type, sourceSpan, leadingComments); } override isEquivalent(e: Expression): boolean { @@ -350,8 +358,9 @@ export class TypeofExpr extends Expression { public expr: Expression, type?: Type | null, sourceSpan?: ParseSourceSpan | null, + leadingComments?: LeadingComment[], ) { - super(type, sourceSpan); + super(type, sourceSpan, leadingComments); } override visitExpression(visitor: ExpressionVisitor, context: any) { @@ -376,8 +385,9 @@ export class VoidExpr extends Expression { public expr: Expression, type?: Type | null, sourceSpan?: ParseSourceSpan | null, + leadingComments?: LeadingComment[], ) { - super(type, sourceSpan); + super(type, sourceSpan, leadingComments); } override visitExpression(visitor: ExpressionVisitor, context: any) { @@ -402,8 +412,9 @@ export class WrappedNodeExpr extends Expression { public node: T, type?: Type | null, sourceSpan?: ParseSourceSpan | null, + leadingComments?: LeadingComment[], ) { - super(type, sourceSpan); + super(type, sourceSpan, leadingComments); } override isEquivalent(e: Expression): boolean { @@ -430,8 +441,9 @@ export class InvokeFunctionExpr extends Expression { type?: Type | null, sourceSpan?: ParseSourceSpan | null, public pure = false, + leadingComments?: LeadingComment[], ) { - super(type, sourceSpan); + super(type, sourceSpan, leadingComments); } // An alias for fn, which allows other logic to handle calls and property reads together. @@ -473,8 +485,9 @@ export class TaggedTemplateLiteralExpr extends Expression { public template: TemplateLiteralExpr, type?: Type | null, sourceSpan?: ParseSourceSpan | null, + leadingComments?: LeadingComment[], ) { - super(type, sourceSpan); + super(type, sourceSpan, leadingComments); } override isEquivalent(e: Expression): boolean { @@ -509,8 +522,9 @@ export class InstantiateExpr extends Expression { public args: Expression[], type?: Type | null, sourceSpan?: ParseSourceSpan | null, + leadingComments?: LeadingComment[], ) { - super(type, sourceSpan); + super(type, sourceSpan, leadingComments); } override isEquivalent(e: Expression): boolean { @@ -544,8 +558,9 @@ export class RegularExpressionLiteralExpr extends Expression { public body: string, public flags: string | null, sourceSpan?: ParseSourceSpan | null, + leadingComments?: LeadingComment[], ) { - super(null, sourceSpan); + super(null, sourceSpan, leadingComments); } override isEquivalent(e: Expression): boolean { @@ -572,8 +587,9 @@ export class LiteralExpr extends Expression { public value: number | string | boolean | null | undefined, type?: Type | null, sourceSpan?: ParseSourceSpan | null, + leadingComments?: LeadingComment[], ) { - super(type, sourceSpan); + super(type, sourceSpan, leadingComments); } override isEquivalent(e: Expression): boolean { @@ -598,8 +614,9 @@ export class TemplateLiteralExpr extends Expression { public elements: TemplateLiteralElementExpr[], public expressions: Expression[], sourceSpan?: ParseSourceSpan | null, + leadingComments?: LeadingComment[], ) { - super(null, sourceSpan); + super(null, sourceSpan, leadingComments); } override isEquivalent(e: Expression): boolean { @@ -632,8 +649,9 @@ export class TemplateLiteralElementExpr extends Expression { readonly text: string, sourceSpan?: ParseSourceSpan | null, rawText?: string, + leadingComments?: LeadingComment[], ) { - super(STRING_TYPE, sourceSpan); + super(STRING_TYPE, sourceSpan, leadingComments); // If `rawText` is not provided, "fake" the raw string by escaping the following sequences: // - "\" would otherwise indicate that the next character is a control character. @@ -699,8 +717,9 @@ export class LocalizedString extends Expression { readonly placeHolderNames: PlaceholderPiece[], readonly expressions: Expression[], sourceSpan?: ParseSourceSpan | null, + leadingComments?: LeadingComment[], ) { - super(STRING_TYPE, sourceSpan); + super(STRING_TYPE, sourceSpan, leadingComments); } override isEquivalent(e: Expression): boolean { @@ -851,8 +870,9 @@ export class ExternalExpr extends Expression { type?: Type | null, public typeParams: Type[] | null = null, sourceSpan?: ParseSourceSpan | null, + leadingComments?: LeadingComment[], ) { - super(type, sourceSpan); + super(type, sourceSpan, leadingComments); } override isEquivalent(e: Expression): boolean { @@ -893,8 +913,9 @@ export class ConditionalExpr extends Expression { public falseCase: Expression | null = null, type?: Type | null, sourceSpan?: ParseSourceSpan | null, + leadingComments?: LeadingComment[], ) { - super(type || trueCase.type, sourceSpan); + super(type || trueCase.type, sourceSpan, leadingComments); this.trueCase = trueCase; } @@ -931,8 +952,9 @@ export class DynamicImportExpr extends Expression { public url: string | Expression, sourceSpan?: ParseSourceSpan | null, public urlComment?: string, + leadingComments?: LeadingComment[], ) { - super(null, sourceSpan); + super(null, sourceSpan, leadingComments); } override isEquivalent(e: Expression): boolean { @@ -960,8 +982,9 @@ export class NotExpr extends Expression { constructor( public condition: Expression, sourceSpan?: ParseSourceSpan | null, + leadingComments?: LeadingComment[], ) { - super(BOOL_TYPE, sourceSpan); + super(BOOL_TYPE, sourceSpan, leadingComments); } override isEquivalent(e: Expression): boolean { @@ -1003,8 +1026,9 @@ export class FunctionExpr extends Expression { type?: Type | null, sourceSpan?: ParseSourceSpan | null, public name?: string | null, + leadingComments?: LeadingComment[], ) { - super(type, sourceSpan); + super(type, sourceSpan, leadingComments); } override isEquivalent(e: Expression | Statement): boolean { @@ -1055,8 +1079,9 @@ export class ArrowFunctionExpr extends Expression { public body: Expression | Statement[], type?: Type | null, sourceSpan?: ParseSourceSpan | null, + leadingComments?: LeadingComment[], ) { - super(type, sourceSpan); + super(type, sourceSpan, leadingComments); } override isEquivalent(e: Expression): boolean { @@ -1105,8 +1130,9 @@ export class UnaryOperatorExpr extends Expression { type?: Type | null, sourceSpan?: ParseSourceSpan | null, public parens: boolean = true, + leadingComments?: LeadingComment[], ) { - super(type || NUMBER_TYPE, sourceSpan); + super(type || NUMBER_TYPE, sourceSpan, leadingComments); } override isEquivalent(e: Expression): boolean { @@ -1141,8 +1167,9 @@ export class ParenthesizedExpr extends Expression { public expr: Expression, type?: Type | null, sourceSpan?: ParseSourceSpan | null, + leadingComments?: LeadingComment[], ) { - super(type, sourceSpan); + super(type, sourceSpan, leadingComments); } override visitExpression(visitor: ExpressionVisitor, context: any) { @@ -1171,8 +1198,9 @@ export class BinaryOperatorExpr extends Expression { public rhs: Expression, type?: Type | null, sourceSpan?: ParseSourceSpan | null, + leadingComments?: LeadingComment[], ) { - super(type || lhs.type, sourceSpan); + super(type || lhs.type, sourceSpan, leadingComments); this.lhs = lhs; } @@ -1226,8 +1254,9 @@ export class ReadPropExpr extends Expression { public name: string, type?: Type | null, sourceSpan?: ParseSourceSpan | null, + leadingComments?: LeadingComment[], ) { - super(type, sourceSpan); + super(type, sourceSpan, leadingComments); } // An alias for name, which allows other logic to handle property reads and keyed reads together. @@ -1270,8 +1299,9 @@ export class ReadKeyExpr extends Expression { public index: Expression, type?: Type | null, sourceSpan?: ParseSourceSpan | null, + leadingComments?: LeadingComment[], ) { - super(type, sourceSpan); + super(type, sourceSpan, leadingComments); } override isEquivalent(e: Expression): boolean { @@ -1307,8 +1337,13 @@ export class ReadKeyExpr extends Expression { export class LiteralArrayExpr extends Expression { public entries: Expression[]; - constructor(entries: Expression[], type?: Type | null, sourceSpan?: ParseSourceSpan | null) { - super(type, sourceSpan); + constructor( + entries: Expression[], + type?: Type | null, + sourceSpan?: ParseSourceSpan | null, + leadingComments?: LeadingComment[], + ) { + super(type, sourceSpan, leadingComments); this.entries = entries; } @@ -1376,8 +1411,9 @@ export class LiteralMapExpr extends Expression { public entries: LiteralMapEntry[], type?: MapType | null, sourceSpan?: ParseSourceSpan | null, + leadingComments?: LeadingComment[], ) { - super(type, sourceSpan); + super(type, sourceSpan, leadingComments); if (type) { this.valueType = type.valueType; } @@ -1405,8 +1441,9 @@ export class CommaExpr extends Expression { constructor( public parts: Expression[], sourceSpan?: ParseSourceSpan | null, + leadingComments?: LeadingComment[], ) { - super(parts[parts.length - 1].type, sourceSpan); + super(parts[parts.length - 1].type, sourceSpan, leadingComments); } override isEquivalent(e: Expression): boolean { @@ -1430,8 +1467,9 @@ export class SpreadElementExpr extends Expression { constructor( public expression: Expression, sourceSpan?: ParseSourceSpan | null, + leadingComments?: LeadingComment[], ) { - super(null, sourceSpan); + super(null, sourceSpan, leadingComments); } override isEquivalent(e: Expression): boolean { @@ -1858,8 +1896,9 @@ export function variable( name: string, type?: Type | null, sourceSpan?: ParseSourceSpan | null, + leadingComments?: LeadingComment[], ): ReadVarExpr { - return new ReadVarExpr(name, type, sourceSpan); + return new ReadVarExpr(name, type, sourceSpan, leadingComments); } export function importExpr( From 84de2311baeb18acee8d10c0f8d84b94ae50ad2a Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 13 Mar 2026 12:28:33 +0100 Subject: [PATCH 05/10] refactor(compiler-cli): check if generated code compiles in compliance tests Updates the compliance tests to check if the generated code compiles. --- .../isolated/isolated_compile_spec.ts | 54 +++++------ .../test_cases/isolated/TEST_CASES.json | 92 ------------------- .../arrow_function/test.ngtypecheck.ts | 5 - .../isolated/arrow_function/test.ts | 9 -- .../arrow_function/test_transformed.ts | 17 ---- .../isolated/basic/test.ngtypecheck.ts | 5 - .../test_cases/isolated/basic/test.ts | 9 -- .../isolated/basic/test_transformed.ts | 20 ---- .../test_cases/isolated/embedded_view/test.ts | 9 -- .../embedded_view/test_transformed.ts | 21 ----- .../event_listener/test.ngtypecheck.ts | 5 - .../isolated/event_listener/test.ts | 9 -- .../event_listener/test_transformed.ts | 15 --- .../test_cases/isolated/queries/test.ts | 10 -- .../isolated/queries/test_transformed.ts | 45 --------- .../test_cases/test_case_schema.json | 6 +- .../test_helpers/get_compliance_tests.ts | 7 +- .../compliance/test_helpers/test_runner.ts | 3 + 18 files changed, 32 insertions(+), 309 deletions(-) delete mode 100644 packages/compiler-cli/test/compliance/test_cases/isolated/TEST_CASES.json delete mode 100644 packages/compiler-cli/test/compliance/test_cases/isolated/arrow_function/test.ngtypecheck.ts delete mode 100644 packages/compiler-cli/test/compliance/test_cases/isolated/arrow_function/test.ts delete mode 100644 packages/compiler-cli/test/compliance/test_cases/isolated/arrow_function/test_transformed.ts delete mode 100644 packages/compiler-cli/test/compliance/test_cases/isolated/basic/test.ngtypecheck.ts delete mode 100644 packages/compiler-cli/test/compliance/test_cases/isolated/basic/test.ts delete mode 100644 packages/compiler-cli/test/compliance/test_cases/isolated/basic/test_transformed.ts delete mode 100644 packages/compiler-cli/test/compliance/test_cases/isolated/embedded_view/test.ts delete mode 100644 packages/compiler-cli/test/compliance/test_cases/isolated/embedded_view/test_transformed.ts delete mode 100644 packages/compiler-cli/test/compliance/test_cases/isolated/event_listener/test.ngtypecheck.ts delete mode 100644 packages/compiler-cli/test/compliance/test_cases/isolated/event_listener/test.ts delete mode 100644 packages/compiler-cli/test/compliance/test_cases/isolated/event_listener/test_transformed.ts delete mode 100644 packages/compiler-cli/test/compliance/test_cases/isolated/queries/test.ts delete mode 100644 packages/compiler-cli/test/compliance/test_cases/isolated/queries/test_transformed.ts diff --git a/packages/compiler-cli/test/compliance/isolated/isolated_compile_spec.ts b/packages/compiler-cli/test/compliance/isolated/isolated_compile_spec.ts index 76aeed9dd562..3aafbbf4de80 100644 --- a/packages/compiler-cli/test/compliance/isolated/isolated_compile_spec.ts +++ b/packages/compiler-cli/test/compliance/isolated/isolated_compile_spec.ts @@ -7,51 +7,29 @@ */ import ts from 'typescript'; -import {checkExpectations} from '../test_helpers/check_expectations'; -import {checkNoUnexpectedErrors} from '../test_helpers/check_errors'; import {AbsoluteFsPath, FileSystem} from '../../../src/ngtsc/file_system'; import {NgtscTestCompilerHost} from '../../../src/ngtsc/testing'; import { getBuildOutputDirectory, - initMockTestFileSystem, getOptions, getRootDirectory, + CompileResult, } from '../test_helpers/compile_test'; -import {ComplianceTest, getAllComplianceTests} from '../test_helpers/get_compliance_tests'; +import {ComplianceTest} from '../test_helpers/get_compliance_tests'; import {NgtscIsolatedPreprocessor} from '@angular/compiler-cli/src/ngtsc/preprocessor'; +import {runTests} from '../test_helpers/test_runner'; -describe('isolated compliance tests', () => { - for (const test of getAllComplianceTests()) { - if (!test.relativePath.includes('isolated')) { - continue; - } - describe(`[${test.description}]`, () => { - (test.focusTest ? fit : it)(test.description, () => { - const fs = initMockTestFileSystem(test.realTestPath); - const {errors} = compileTests(fs, test); - for (const expectation of test.expectations) { - checkExpectations( - fs, - test.relativePath, - expectation.failureMessage, - expectation.files, - expectation.extraChecks, - ); - checkNoUnexpectedErrors(test.relativePath, errors); - } - }); - }); - } +runTests('instruction compile', compileTests, { + checkErrorsOnly: true, }); -function compileTests(fs: FileSystem, test: ComplianceTest): {errors: string[]} { +function compileTests(fs: FileSystem, test: ComplianceTest): CompileResult { const rootDir = getRootDirectory(fs); const outDir = getBuildOutputDirectory(fs); const compilerOptions = test.compilerOptions; const angularCompilerOptions = test.angularCompilerOptions; const options = getOptions(rootDir, outDir, compilerOptions, angularCompilerOptions); - // Resolve inputs relative to rootDir. const rootNames = test.inputFiles.map((f) => fs.resolve(rootDir, f)); const host = new NgtscTestCompilerHost(fs, options); @@ -63,6 +41,10 @@ function compileTests(fs: FileSystem, test: ComplianceTest): {errors: string[]} const validFiles = new Set(); for (const file of transformedFiles) { + if (file.fileName.includes('ngtypecheck.ts')) { + continue; + } + const relativePath = fs.relative(rootDir, fs.resolve(file.fileName)); const path = fs.resolve(outDir, relativePath); fs.ensureDir(fs.dirname(path)); @@ -72,6 +54,9 @@ function compileTests(fs: FileSystem, test: ComplianceTest): {errors: string[]} } const verifyHost = new NgtscTestCompilerHost(fs, options); + const extraPaths = test.compilerOptions?.['paths'] as unknown as + | Record + | undefined; const verifyProgram = ts.createProgram({ rootNames: [...emittedFiles], options: { @@ -80,6 +65,7 @@ function compileTests(fs: FileSystem, test: ComplianceTest): {errors: string[]} skipLibCheck: true, paths: { '*': ['./node_modules/*'], + ...extraPaths, }, // Use classic Node resolution which works better with the simple mock FS structure // than 'Bundler' or 'NodeNext' which expect specific package.json exports. @@ -87,6 +73,7 @@ function compileTests(fs: FileSystem, test: ComplianceTest): {errors: string[]} module: ts.ModuleKind.Node16, strict: true, target: ts.ScriptTarget.ES2015, + experimentalDecorators: true, types: [], }, host: verifyHost, @@ -95,11 +82,12 @@ function compileTests(fs: FileSystem, test: ComplianceTest): {errors: string[]} const verifyDiags = ts.getPreEmitDiagnostics(verifyProgram); return { - errors: verifyDiags.map((d) => { - let message = ts.flattenDiagnosticMessageText(d.messageText, '\n'); - if (d.file) { - const {line, character} = d.file.getLineAndCharacterOfPosition(d.start!); - message = `${d.file.fileName} (${line + 1},${character + 1}): ${message}`; + emittedFiles: [], + errors: verifyDiags.map((diagnostic) => { + let message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n'); + if (diagnostic.file) { + const {line, character} = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start!); + message = `${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`; } return message; }), diff --git a/packages/compiler-cli/test/compliance/test_cases/isolated/TEST_CASES.json b/packages/compiler-cli/test/compliance/test_cases/isolated/TEST_CASES.json deleted file mode 100644 index 94affde1f237..000000000000 --- a/packages/compiler-cli/test/compliance/test_cases/isolated/TEST_CASES.json +++ /dev/null @@ -1,92 +0,0 @@ -{ - "$schema": "../test_case_schema.json", - "cases": [ - { - "description": "basic component transformation", - "inputFiles": ["basic/test.ts"], - "compilationModeFilter": [], - "expectations": [ - { - "files": [ - { - "expected": "basic/test_transformed.ts", - "generated": "basic/test.ts" - }, - { - "expected": "basic/test.ngtypecheck.ts", - "generated": "basic/test.ngtypecheck.ts" - } - ] - } - ] - }, - { - "description": "component with an embedded view", - "inputFiles": ["embedded_view/test.ts"], - "compilationModeFilter": [], - "expectations": [ - { - "files": [ - { - "expected": "embedded_view/test_transformed.ts", - "generated": "embedded_view/test.ts" - } - ] - } - ] - }, - { - "description": "component with an event listener", - "inputFiles": ["event_listener/test.ts"], - "compilationModeFilter": [], - "expectations": [ - { - "files": [ - { - "expected": "event_listener/test_transformed.ts", - "generated": "event_listener/test.ts" - }, - { - "expected": "event_listener/test.ngtypecheck.ts", - "generated": "event_listener/test.ngtypecheck.ts" - } - ] - } - ] - }, - { - "description": "component with an arrow function", - "inputFiles": ["arrow_function/test.ts"], - "compilationModeFilter": [], - "expectations": [ - { - "files": [ - { - "expected": "arrow_function/test_transformed.ts", - "generated": "arrow_function/test.ts" - }, - { - "expected": "arrow_function/test.ngtypecheck.ts", - "generated": "arrow_function/test.ngtypecheck.ts" - } - ] - } - ] - }, - { - "description": "component using queries", - "inputFiles": ["queries/test.ts"], - "compilationModeFilter": [], - "expectations": [ - { - "files": [ - { - "expected": "queries/test_transformed.ts", - "generated": "queries/test.ts" - } - ] - } - ] - } - ] -} diff --git a/packages/compiler-cli/test/compliance/test_cases/isolated/arrow_function/test.ngtypecheck.ts b/packages/compiler-cli/test/compliance/test_cases/isolated/arrow_function/test.ngtypecheck.ts deleted file mode 100644 index a7d18fb57dd5..000000000000 --- a/packages/compiler-cli/test/compliance/test_cases/isolated/arrow_function/test.ngtypecheck.ts +++ /dev/null @@ -1,5 +0,0 @@ -… -($event: any /*T:EP*/): any => { - (((this).value /*117,122*/) /*117,122*/).update /*123,129*/(prev /*D:ignore*/ => (prev /*138,142*/) + (1 /*145,146*/) /*138,146*/) /*117,147*/; -}; -… diff --git a/packages/compiler-cli/test/compliance/test_cases/isolated/arrow_function/test.ts b/packages/compiler-cli/test/compliance/test_cases/isolated/arrow_function/test.ts deleted file mode 100644 index 8d065ce74b89..000000000000 --- a/packages/compiler-cli/test/compliance/test_cases/isolated/arrow_function/test.ts +++ /dev/null @@ -1,9 +0,0 @@ -import {Component, signal} from '@angular/core'; - -@Component({ - selector: 'test-cmp', - template: '', -}) -export class TestCmp { - value = signal(1); -} diff --git a/packages/compiler-cli/test/compliance/test_cases/isolated/arrow_function/test_transformed.ts b/packages/compiler-cli/test/compliance/test_cases/isolated/arrow_function/test_transformed.ts deleted file mode 100644 index db5125d1b1e2..000000000000 --- a/packages/compiler-cli/test/compliance/test_cases/isolated/arrow_function/test_transformed.ts +++ /dev/null @@ -1,17 +0,0 @@ -$r3$.ɵɵdefineComponent({ - type: TestCmp, - selectors: [["test-cmp"]], - decls: 1, - vars: 0, - consts: [[3, "click"]], - template: function TestCmp_Template(rf: number, ctx: any) { - if (rf & 1) { - $r3$.ɵɵdomElementStart(0, "button", 0); - $r3$.ɵɵdomListener("click", function TestCmp_Template_button_click_0_listener() { - return ctx.value.update((prev: any) => prev + 1); - }); - $r3$.ɵɵdomElementEnd(); - } - }, - encapsulation: 2 -}); diff --git a/packages/compiler-cli/test/compliance/test_cases/isolated/basic/test.ngtypecheck.ts b/packages/compiler-cli/test/compliance/test_cases/isolated/basic/test.ngtypecheck.ts deleted file mode 100644 index 36e42891681c..000000000000 --- a/packages/compiler-cli/test/compliance/test_cases/isolated/basic/test.ngtypecheck.ts +++ /dev/null @@ -1,5 +0,0 @@ - import * as i0 from './test'; - import * as i1 from '@angular/core'; -… - "" + ((((((this).x /*94,95*/) /*94,95*/)!.toString /*97,105*/ as any) /*94,105*/ as any)() /*94,107*/); -… diff --git a/packages/compiler-cli/test/compliance/test_cases/isolated/basic/test.ts b/packages/compiler-cli/test/compliance/test_cases/isolated/basic/test.ts deleted file mode 100644 index 095d7821b7b0..000000000000 --- a/packages/compiler-cli/test/compliance/test_cases/isolated/basic/test.ts +++ /dev/null @@ -1,9 +0,0 @@ -import {Component} from '@angular/core'; - -@Component({ - selector: 'test-cmp', - template: '{{x?.toString()}}', -}) -export class TestCmp { - x?: string; -} diff --git a/packages/compiler-cli/test/compliance/test_cases/isolated/basic/test_transformed.ts b/packages/compiler-cli/test/compliance/test_cases/isolated/basic/test_transformed.ts deleted file mode 100644 index adce51ea8d53..000000000000 --- a/packages/compiler-cli/test/compliance/test_cases/isolated/basic/test_transformed.ts +++ /dev/null @@ -1,20 +0,0 @@ -… -static ɵfac: $r3$.ɵɵFactoryDeclaration = function TestCmp_Factory(__ngFactoryType__: any) { - return new (__ngFactoryType__ || TestCmp)(); -}; - -static ɵcmp: $r3$.ɵɵComponentDeclaration = /*@__PURE__*/ - $r3$.ɵɵdefineComponent({ - type: TestCmp, - selectors: [["test-cmp"]], - decls: 1, - vars: 1, - template: function TestCmp_Template(rf: number, ctx: any) { - if (rf & 1) { - $r3$.ɵɵtext(0); - } - if (rf & 2) { - $r3$.ɵɵtextInterpolate(ctx.x == null ? null : ctx.x.toString()); - } - }, encapsulation: 2 }); -… diff --git a/packages/compiler-cli/test/compliance/test_cases/isolated/embedded_view/test.ts b/packages/compiler-cli/test/compliance/test_cases/isolated/embedded_view/test.ts deleted file mode 100644 index 743409ccde47..000000000000 --- a/packages/compiler-cli/test/compliance/test_cases/isolated/embedded_view/test.ts +++ /dev/null @@ -1,9 +0,0 @@ -import {Component} from '@angular/core'; - -@Component({ - selector: 'test-cmp', - template: '{{x}}', -}) -export class TestCmp { - x = 'hello'; -} diff --git a/packages/compiler-cli/test/compliance/test_cases/isolated/embedded_view/test_transformed.ts b/packages/compiler-cli/test/compliance/test_cases/isolated/embedded_view/test_transformed.ts deleted file mode 100644 index 8676cc4b8c05..000000000000 --- a/packages/compiler-cli/test/compliance/test_cases/isolated/embedded_view/test_transformed.ts +++ /dev/null @@ -1,21 +0,0 @@ -function TestCmp_ng_template_0_Template(rf: number, ctx: any) { - if (rf & 1) { - $r3$.ɵɵtext(0); - } - if (rf & 2) { - const ctx_r0 = $r3$.ɵɵnextContext(); - $r3$.ɵɵtextInterpolate(ctx_r0.x); - } -} -… -$r3$.ɵɵdefineComponent({ - type: TestCmp, - selectors: [["test-cmp"]], - decls: 1, vars: 0, - template: function TestCmp_Template(rf: number, ctx: any) { - if (rf & 1) { - $r3$.ɵɵdomTemplate(0, TestCmp_ng_template_0_Template, 1, 1, "ng-template"); - } - }, - encapsulation: 2 -}) diff --git a/packages/compiler-cli/test/compliance/test_cases/isolated/event_listener/test.ngtypecheck.ts b/packages/compiler-cli/test/compliance/test_cases/isolated/event_listener/test.ngtypecheck.ts deleted file mode 100644 index f3e2ae0949b7..000000000000 --- a/packages/compiler-cli/test/compliance/test_cases/isolated/event_listener/test.ngtypecheck.ts +++ /dev/null @@ -1,5 +0,0 @@ -… -($event: any /*T:EP*/): any => { - (this).handleClick /*109,120*/($event /*121,127*/) /*109,128*/; -}; -… diff --git a/packages/compiler-cli/test/compliance/test_cases/isolated/event_listener/test.ts b/packages/compiler-cli/test/compliance/test_cases/isolated/event_listener/test.ts deleted file mode 100644 index 597fe97f3729..000000000000 --- a/packages/compiler-cli/test/compliance/test_cases/isolated/event_listener/test.ts +++ /dev/null @@ -1,9 +0,0 @@ -import {Component} from '@angular/core'; - -@Component({ - selector: 'test-cmp', - template: '', -}) -export class TestCmp { - handleClick(event: MouseEvent) {} -} diff --git a/packages/compiler-cli/test/compliance/test_cases/isolated/event_listener/test_transformed.ts b/packages/compiler-cli/test/compliance/test_cases/isolated/event_listener/test_transformed.ts deleted file mode 100644 index 26c756f503fc..000000000000 --- a/packages/compiler-cli/test/compliance/test_cases/isolated/event_listener/test_transformed.ts +++ /dev/null @@ -1,15 +0,0 @@ -$r3$.ɵɵdefineComponent({ - type: TestCmp, - selectors: [["test-cmp"]], - decls: 1, - vars: 0, - consts: [[3, "click"]], - template: function TestCmp_Template(rf: number, ctx: any) { - if (rf & 1) { - $r3$.ɵɵdomElementStart(0, "button", 0); - $r3$.ɵɵdomListener("click", function TestCmp_Template_button_click_0_listener($event: any) { return ctx.handleClick($event); }); - $r3$.ɵɵdomElementEnd(); - } - }, - encapsulation: 2 -}); diff --git a/packages/compiler-cli/test/compliance/test_cases/isolated/queries/test.ts b/packages/compiler-cli/test/compliance/test_cases/isolated/queries/test.ts deleted file mode 100644 index dbe7cf46204d..000000000000 --- a/packages/compiler-cli/test/compliance/test_cases/isolated/queries/test.ts +++ /dev/null @@ -1,10 +0,0 @@ -import {Component, ContentChildren, ElementRef, QueryList, ViewChild} from '@angular/core'; - -@Component({ - selector: 'test-cmp', - template: '', -}) -export class TestCmp { - @ViewChild('span') span: ElementRef = null!; - @ContentChildren('projected') projected: QueryList = null!; -} diff --git a/packages/compiler-cli/test/compliance/test_cases/isolated/queries/test_transformed.ts b/packages/compiler-cli/test/compliance/test_cases/isolated/queries/test_transformed.ts deleted file mode 100644 index 43b83064ce7f..000000000000 --- a/packages/compiler-cli/test/compliance/test_cases/isolated/queries/test_transformed.ts +++ /dev/null @@ -1,45 +0,0 @@ -const _c0 = ["projected"]; -const _c1 = ["span"]; -const _c2 = ["*"]; -… -static ɵfac: $r3$.ɵɵFactoryDeclaration = function TestCmp_Factory(__ngFactoryType__: any) { - return new (__ngFactoryType__ || TestCmp)(); -}; - -static ɵcmp: $r3$.ɵɵComponentDeclaration = /*@__PURE__*/ - $r3$.ɵɵdefineComponent({ - type: TestCmp, - selectors: [["test-cmp"]], - contentQueries: function TestCmp_ContentQueries(rf: number, ctx: any, dirIndex: number) { - if (rf & 1) { - $r3$.ɵɵcontentQuery(dirIndex, _c0, 4); - } - if (rf & 2) { - let _t: any; - $r3$.ɵɵqueryRefresh(_t = $r3$.ɵɵloadQuery()) && (ctx.projected = _t); - } - }, - viewQuery: function TestCmp_Query(rf: number, ctx: any) { - if (rf & 1) { - $r3$.ɵɵviewQuery(_c1, 5); - } - if (rf & 2) { - let _t: any; - $r3$.ɵɵqueryRefresh(_t = $r3$.ɵɵloadQuery()) && (ctx.span = _t.first); - } - }, - ngContentSelectors: _c2, - decls: 3, - vars: 0, - consts: [["span", ""]], - template: function TestCmp_Template(rf: number, ctx: any) { - if (rf & 1) { - $r3$.ɵɵprojectionDef(); - $r3$.ɵɵdomElementStart(0, "span", null, 0); - $r3$.ɵɵprojection(2); - $r3$.ɵɵdomElementEnd(); - } - }, - encapsulation: 2 - }); -… diff --git a/packages/compiler-cli/test/compliance/test_cases/test_case_schema.json b/packages/compiler-cli/test/compliance/test_cases/test_case_schema.json index a9a8a7e8587f..ac25d626e229 100644 --- a/packages/compiler-cli/test/compliance/test_cases/test_case_schema.json +++ b/packages/compiler-cli/test/compliance/test_cases/test_case_schema.json @@ -27,13 +27,15 @@ "full compile", "linked compile", "local compile", - "declaration-only emit" + "declaration-only emit", + "instruction compile" ] }, "default": [ "full compile", "linked compile", - "declaration-only emit" + "declaration-only emit", + "instruction compile" ] }, "inputFiles": { diff --git a/packages/compiler-cli/test/compliance/test_helpers/get_compliance_tests.ts b/packages/compiler-cli/test/compliance/test_helpers/get_compliance_tests.ts index 75a25fdee9d5..cd3fef979609 100644 --- a/packages/compiler-cli/test/compliance/test_helpers/get_compliance_tests.ts +++ b/packages/compiler-cli/test/compliance/test_helpers/get_compliance_tests.ts @@ -50,7 +50,7 @@ export function* getComplianceTests(absTestConfigPath: AbsoluteFsPath): Generato test, 'compilationModeFilter', realTestPath, - ['linked compile', 'full compile', 'declaration-only emit'], + ['linked compile', 'full compile', 'declaration-only emit', 'instruction compile'], ) as CompilationMode[]; yield { @@ -297,7 +297,8 @@ export type CompilationMode = | 'linked compile' | 'full compile' | 'local compile' - | 'declaration-only emit'; + | 'declaration-only emit' + | 'instruction compile'; export interface Expectation { /** The message to display if this expectation fails. */ @@ -342,7 +343,7 @@ export type ConfigOptions = Record; */ export interface TestCaseJson { description: string; - compilationModeFilter?: ('fulll compile' | 'linked compile')[]; + compilationModeFilter?: CompilationMode[]; inputFiles?: string[]; expectations?: { failureMessage?: string; diff --git a/packages/compiler-cli/test/compliance/test_helpers/test_runner.ts b/packages/compiler-cli/test/compliance/test_helpers/test_runner.ts index 20445e92922b..4e356ab47820 100644 --- a/packages/compiler-cli/test/compliance/test_helpers/test_runner.ts +++ b/packages/compiler-cli/test/compliance/test_helpers/test_runner.ts @@ -52,6 +52,7 @@ export function runTests( isLocalCompilation?: boolean; emitDeclarationOnly?: boolean; skipMappingChecks?: boolean; + checkErrorsOnly?: boolean; } = {}, ) { describe(`compliance tests (${type})`, () => { @@ -85,6 +86,8 @@ export function runTests( expectation.expectedErrors, errors, ); + } else if (options.checkErrorsOnly) { + checkNoUnexpectedErrors(test.relativePath, errors); } else if (!!options.emitDeclarationOnly) { checkNoUnexpectedErrors(test.relativePath, errors); checkTypeDeclarations(fs, emittedFiles); From 3c6fc812ea19ce4c7d54bfb850e36caacdfa399a Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 13 Mar 2026 12:30:14 +0100 Subject: [PATCH 06/10] refactor(compiler): add type annotations to generated code Adds explicit type annotations to the generated code so it's able to compile. --- packages/compiler/src/render3/r3_factory.ts | 10 ++++++++-- .../pipeline/src/phases/i18n_const_collection.ts | 2 +- .../src/template/pipeline/src/phases/reify.ts | 14 ++++++++++++-- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/packages/compiler/src/render3/r3_factory.ts b/packages/compiler/src/render3/r3_factory.ts index 43d910babb65..a6f73dba1ba6 100644 --- a/packages/compiler/src/render3/r3_factory.ts +++ b/packages/compiler/src/render3/r3_factory.ts @@ -133,7 +133,7 @@ export function compileFactoryFunction(meta: R3FactoryMetadata): R3CompiledExpre function makeConditionalFactory(nonCtorExpr: o.Expression): o.ReadVarExpr { const r = o.variable('__ngConditionalFactory__'); - body.push(new o.DeclareVarStmt(r.name, o.NULL_EXPR, o.INFERRED_TYPE)); + body.push(new o.DeclareVarStmt(r.name, o.NULL_EXPR, o.DYNAMIC_TYPE)); const ctorStmt = ctorExpr !== null ? r.set(ctorExpr).toStmt() @@ -188,7 +188,13 @@ export function compileFactoryFunction(meta: R3FactoryMetadata): R3CompiledExpre // There is a base factory variable so wrap its declaration along with the factory function into // an IIFE. factoryFn = o - .arrowFn([], [new o.DeclareVarStmt(baseFactoryVar.name!), new o.ReturnStatement(factoryFn)]) + .arrowFn( + [], + [ + new o.DeclareVarStmt(baseFactoryVar.name!, undefined, o.DYNAMIC_TYPE), + new o.ReturnStatement(factoryFn), + ], + ) .callFn([], /* sourceSpan */ undefined, /* pure */ true); } diff --git a/packages/compiler/src/template/pipeline/src/phases/i18n_const_collection.ts b/packages/compiler/src/template/pipeline/src/phases/i18n_const_collection.ts index 714d26951d69..2d481ee1ece0 100644 --- a/packages/compiler/src/template/pipeline/src/phases/i18n_const_collection.ts +++ b/packages/compiler/src/template/pipeline/src/phases/i18n_const_collection.ts @@ -246,7 +246,7 @@ function collectMessage( // Sort the params for consistency with TemaplateDefinitionBuilder output. messageOp.params = new Map([...messageOp.params.entries()].sort()); - const mainVar = o.variable(job.pool.uniqueName(TRANSLATION_VAR_PREFIX)); + const mainVar = o.variable(job.pool.uniqueName(TRANSLATION_VAR_PREFIX), o.DYNAMIC_TYPE); // Closure Compiler requires const names to start with `MSG_` but disallows any other // const to start with `MSG_`. We define a variable starting with `MSG_` just for the // `goog.getMsg` call diff --git a/packages/compiler/src/template/pipeline/src/phases/reify.ts b/packages/compiler/src/template/pipeline/src/phases/reify.ts index 3b064be9448e..34a190eb4a32 100644 --- a/packages/compiler/src/template/pipeline/src/phases/reify.ts +++ b/packages/compiler/src/template/pipeline/src/phases/reify.ts @@ -342,7 +342,12 @@ function reifyCreateOperations(unit: CompilationUnit, ops: ir.OpList( op, ir.createStatementOp( - new o.DeclareVarStmt(op.variable.name, op.initializer, undefined, o.StmtModifier.Final), + new o.DeclareVarStmt( + op.variable.name, + op.initializer, + o.DYNAMIC_TYPE, + o.StmtModifier.Final, + ), ), ); break; @@ -693,7 +698,12 @@ function reifyUpdateOperations(unit: CompilationUnit, ops: ir.OpList( op, ir.createStatementOp( - new o.DeclareVarStmt(op.variable.name, op.initializer, undefined, o.StmtModifier.Final), + new o.DeclareVarStmt( + op.variable.name, + op.initializer, + o.DYNAMIC_TYPE, + o.StmtModifier.Final, + ), ), ); break; From 5464e478ff6f0fa1e3c08e1f4a0407fe6f017d55 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 13 Mar 2026 12:36:00 +0100 Subject: [PATCH 07/10] refactor(compiler): add ts-ignore in pipeline Adds `@ts-ignore` comments to same places in the pipeline where we can't produce code that passes all type checks. --- .../src/render3/r3_class_metadata_compiler.ts | 10 ++++++++-- packages/compiler/src/render3/util.ts | 4 ++++ packages/compiler/src/render3/view/compiler.ts | 18 +++++++++++++++--- .../src/render3/view/i18n/get_msg_utils.ts | 8 ++++---- .../src/render3/view/i18n/localize_utils.ts | 7 ++++++- .../src/phases/track_fn_optimization.ts | 9 ++++++++- 6 files changed, 45 insertions(+), 11 deletions(-) diff --git a/packages/compiler/src/render3/r3_class_metadata_compiler.ts b/packages/compiler/src/render3/r3_class_metadata_compiler.ts index adc42e902ec6..07632fb2e4a8 100644 --- a/packages/compiler/src/render3/r3_class_metadata_compiler.ts +++ b/packages/compiler/src/render3/r3_class_metadata_compiler.ts @@ -8,7 +8,7 @@ import * as o from '../output/output_ast'; import {Identifiers as R3} from './r3_identifiers'; -import {devOnlyGuardedExpression} from './util'; +import {devOnlyGuardedExpression, tsIgnoreComment} from './util'; import {R3DeferPerComponentDependency} from './view/api'; export type CompileClassMetadataFn = (metadata: R3ClassMetadata) => o.Expression; @@ -150,7 +150,13 @@ export function compileComponentMetadataAsyncResolver( ); // e.g. `import('./cmp-a').then(...)` - return new o.DynamicImportExpr(importPath).prop('then').callFn([innerFn]); + return new o.DynamicImportExpr(importPath) + .prop('then') + .callFn([innerFn], undefined, undefined, [ + // Necessary, because we might not generate extensions for the path + // and TS may try to enforce it based on the compiler options. + tsIgnoreComment(), + ]); }); // e.g. `() => [ ... ];` diff --git a/packages/compiler/src/render3/util.ts b/packages/compiler/src/render3/util.ts index e12dd0d23418..f03383668a19 100644 --- a/packages/compiler/src/render3/util.ts +++ b/packages/compiler/src/render3/util.ts @@ -89,6 +89,10 @@ export function refsToArray(refs: R3Reference[], shouldForwardDeclare: boolean): return shouldForwardDeclare ? o.arrowFn([], values) : values; } +export function tsIgnoreComment(): o.LeadingComment { + return o.leadingComment('@ts-ignore', true, true); +} + /** * Describes an expression that may have been wrapped in a `forwardRef()` guard. * diff --git a/packages/compiler/src/render3/view/compiler.ts b/packages/compiler/src/render3/view/compiler.ts index 5316dce25a4c..b247f53aa44f 100644 --- a/packages/compiler/src/render3/view/compiler.ts +++ b/packages/compiler/src/render3/view/compiler.ts @@ -16,7 +16,7 @@ import {emitHostBindingFunction, emitTemplateFn, transform} from '../../template import {ingestComponent, ingestHostBinding} from '../../template/pipeline/src/ingest'; import {BindingParser} from '../../template_parser/binding_parser'; import {Identifiers as R3} from '../r3_identifiers'; -import {R3CompiledExpression, typeWithParameters} from '../util'; +import {R3CompiledExpression, tsIgnoreComment, typeWithParameters} from '../util'; import { DeclarationListEmitMode, @@ -746,7 +746,13 @@ export function compileDeferResolverFunction( ); // Dynamic import, e.g. `import('./a').then(...)`. - const importExpr = new o.DynamicImportExpr(dep.importPath!).prop('then').callFn([innerFn]); + const importExpr = new o.DynamicImportExpr(dep.importPath!) + .prop('then') + .callFn([innerFn], undefined, undefined, [ + // Necessary, because we might not generate extensions for the path + // and TS may try to enforce it based on the compiler options. + tsIgnoreComment(), + ]); depExpressions.push(importExpr); } else { // Non-deferrable symbol, just use a reference to the type. Note that it's important to @@ -764,7 +770,13 @@ export function compileDeferResolverFunction( ); // Dynamic import, e.g. `import('./a').then(...)`. - const importExpr = new o.DynamicImportExpr(importPath).prop('then').callFn([innerFn]); + const importExpr = new o.DynamicImportExpr(importPath) + .prop('then') + .callFn([innerFn], undefined, undefined, [ + // Necessary, because we might not generate extensions for the path + // and TS may try to enforce it based on the compiler options. + tsIgnoreComment(), + ]); depExpressions.push(importExpr); } } diff --git a/packages/compiler/src/render3/view/i18n/get_msg_utils.ts b/packages/compiler/src/render3/view/i18n/get_msg_utils.ts index 3a54ffa68c42..c0514686c744 100644 --- a/packages/compiler/src/render3/view/i18n/get_msg_utils.ts +++ b/packages/compiler/src/render3/view/i18n/get_msg_utils.ts @@ -8,14 +8,12 @@ import * as i18n from '../../../i18n/i18n_ast'; import {mapLiteral} from '../../../output/map_util'; import * as o from '../../../output/output_ast'; +import {tsIgnoreComment} from '../../util'; import {serializeIcuNode} from './icu_serializer'; import {i18nMetaToJSDoc} from './meta'; import {formatI18nPlaceholderName, formatI18nPlaceholderNamesInMap} from './util'; -/** Closure uses `goog.getMsg(message)` to lookup translations */ -const GOOG_GET_MSG = 'goog.getMsg'; - /** * Generates a `goog.getMsg()` statement and reassignment. The template: * @@ -100,7 +98,9 @@ export function createGoogleGetMsgStatements( // I18N_X = MSG_...; const googGetMsgStmt = new o.DeclareVarStmt( closureVar.name, - o.variable(GOOG_GET_MSG).callFn(args), + o.variable('goog').prop('getMsg').callFn(args, null, undefined, [ + tsIgnoreComment(), // `goog` might not be available externally. + ]), o.INFERRED_TYPE, o.StmtModifier.Final, ); diff --git a/packages/compiler/src/render3/view/i18n/localize_utils.ts b/packages/compiler/src/render3/view/i18n/localize_utils.ts index 74cc0befbdab..430a5e7fec88 100644 --- a/packages/compiler/src/render3/view/i18n/localize_utils.ts +++ b/packages/compiler/src/render3/view/i18n/localize_utils.ts @@ -8,6 +8,7 @@ import * as i18n from '../../../i18n/i18n_ast'; import * as o from '../../../output/output_ast'; import {ParseLocation, ParseSourceSpan} from '../../../parse_util'; +import {tsIgnoreComment} from '../../util'; import {serializeIcuNode} from './icu_serializer'; import {formatI18nPlaceholderName} from './util'; @@ -28,7 +29,11 @@ export function createLocalizeStatements( sourceSpan, ); const variableInitialization = variable.set(localizedString); - return [new o.ExpressionStatement(variableInitialization)]; + return [ + new o.ExpressionStatement(variableInitialization, null, [ + tsIgnoreComment(), // `$localize` might not be available internally. + ]), + ]; } /** diff --git a/packages/compiler/src/template/pipeline/src/phases/track_fn_optimization.ts b/packages/compiler/src/template/pipeline/src/phases/track_fn_optimization.ts index a6bfa552035d..3d8758707ed6 100644 --- a/packages/compiler/src/template/pipeline/src/phases/track_fn_optimization.ts +++ b/packages/compiler/src/template/pipeline/src/phases/track_fn_optimization.ts @@ -8,6 +8,7 @@ import * as o from '../../../../output/output_ast'; import {Identifiers} from '../../../../render3/r3_identifiers'; +import {tsIgnoreComment} from '../../../../render3/util'; import * as ir from '../../ir'; import type {CompilationJob} from '../compilation'; @@ -73,7 +74,13 @@ export function optimizeTrackFns(job: CompilationJob): void { // additional ops when generating the final code (e.g. temporary variables). const trackOpList = new ir.OpList(); trackOpList.push( - ir.createStatementOp(new o.ReturnStatement(op.track, op.track.sourceSpan)), + ir.createStatementOp( + new o.ReturnStatement(op.track, op.track.sourceSpan, [ + // The return statement might have `this` expressions + // that are implicitly typed as `any`. + tsIgnoreComment(), + ]), + ), ); op.trackByOps = trackOpList; } From a926341333a7b6ffc85b8350d6350e9d7b7a2497 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 13 Mar 2026 13:27:17 +0100 Subject: [PATCH 08/10] refactor(compiler-cli): avoid typescript errors from debugName transform In some cases the `debugName` transform generates a spread into the signal function parameters. This can cause compiler errors, because the functions don't have rest parameters. These changes work around it by adding a `@ts-ignore` above it. --- .../implicit_signal_debug_name_transform.ts | 25 +- .../test/ngtsc/debug_transform_spec.ts | 278 ++++++++++-------- .../compiler-cli/test/ngtsc/defer_spec.ts | 99 ++++--- .../test/ngtsc/local_compilation_spec.ts | 44 +-- .../test/ngtsc/selectorless_spec.ts | 12 +- 5 files changed, 250 insertions(+), 208 deletions(-) diff --git a/packages/compiler-cli/src/ngtsc/transform/src/implicit_signal_debug_name_transform.ts b/packages/compiler-cli/src/ngtsc/transform/src/implicit_signal_debug_name_transform.ts index b406fc4df548..9fe48a2e082a 100644 --- a/packages/compiler-cli/src/ngtsc/transform/src/implicit_signal_debug_name_transform.ts +++ b/packages/compiler-cli/src/ngtsc/transform/src/implicit_signal_debug_name_transform.ts @@ -68,15 +68,24 @@ function insertDebugNameIntoCallExpression( spreadArgs.push(ts.factory.createObjectLiteralExpression([debugNameProperty])); - newArgs = [ - ...node.arguments, - ts.factory.createSpreadElement( - createNgDevModeConditional( - ts.factory.createArrayLiteralExpression(spreadArgs), - ts.factory.createArrayLiteralExpression(), - ), + const spread = ts.factory.createSpreadElement( + createNgDevModeConditional( + ts.factory.createArrayLiteralExpression(spreadArgs), + ts.factory.createArrayLiteralExpression(), ), - ]; + ); + + // Add a `ts-ignore` on the spread, because it may raise an error that we don't + // have a spread argument in the signature for the specific signal. We don't update + // the source to add the signature to avoid making it harder to read. + ts.addSyntheticLeadingComment( + spread, + ts.SyntaxKind.MultiLineCommentTrivia, + ' @ts-ignore ', + true, + ); + + newArgs = [...node.arguments, spread]; } return ts.factory.updateCallExpression(node, node.expression, node.typeArguments, newArgs); diff --git a/packages/compiler-cli/test/ngtsc/debug_transform_spec.ts b/packages/compiler-cli/test/ngtsc/debug_transform_spec.ts index 6a2f6ecc2fc2..b80b1bba944c 100644 --- a/packages/compiler-cli/test/ngtsc/debug_transform_spec.ts +++ b/packages/compiler-cli/test/ngtsc/debug_transform_spec.ts @@ -69,8 +69,8 @@ runInEachFileSystem(() => { env.driveMain(); const jsContents = env.getContents('test.js'); - expect(jsContents).toContain( - `signal('Hello World', ...(ngDevMode ? [{ debugName: "testSignal" }] : /* istanbul ignore next */ []))`, + expect(cleanNewLines(jsContents)).toContain( + `signal('Hello World', /* @ts-ignore */ ...(ngDevMode ? [{ debugName: "testSignal" }] : /* istanbul ignore next */ []))`, ); }); @@ -88,7 +88,7 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedProdBuildOptions)).code; expect(builtContent).not.toContain('debugName'); - expect(builtContent).toContain('signal("Hello World")'); + expect(cleanNewLines(builtContent)).toContain('signal( "Hello World" )'); }); it('should not tree-shake away debug info if in dev mode', async () => { @@ -103,7 +103,9 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedDevBuildOptions)).code; - expect(builtContent).toContain(`signal("Hello World", { debugName: "testSignal" });`); + expect(cleanNewLines(builtContent)).toContain( + `signal( "Hello World", { debugName: "testSignal" } )`, + ); }); it('should insert debug info into signal function that already has custom options', async () => { @@ -117,7 +119,7 @@ runInEachFileSystem(() => { env.driveMain(); const jsContents = env.getContents('test.js'); - expect(jsContents).toContain( + expect(cleanNewLines(jsContents)).toContain( `signal('Hello World', { ...(ngDevMode ? { debugName: "testSignal" } : /* istanbul ignore next */ {}), equal: () => true })`, ); }); @@ -135,7 +137,7 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedProdBuildOptions)).code; - expect(builtContent).toContain(`signal("Hello World", { equal });`); + expect(cleanNewLines(builtContent)).toContain(`signal("Hello World", { equal })`); expect(builtContent).not.toContain('ngDevMode'); expect(builtContent).not.toContain('debugName'); }); @@ -159,8 +161,8 @@ runInEachFileSystem(() => { env.driveMain(); const jsContents = env.getContents('test.js'); - expect(jsContents).toContain( - `signal('Hello World', ...(ngDevMode ? [{ debugName: "testSignal" }] : /* istanbul ignore next */ [])`, + expect(cleanNewLines(jsContents)).toContain( + `signal('Hello World', /* @ts-ignore */ ...(ngDevMode ? [{ debugName: "testSignal" }] : /* istanbul ignore next */ [])`, ); }); @@ -183,7 +185,7 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedProdBuildOptions)).code; expect(builtContent).not.toContain('debugName'); - expect(builtContent).toContain('signal("Hello World")'); + expect(cleanNewLines(builtContent)).toContain('signal( "Hello World" )'); }); it('should not tree-shake away debug info if in dev mode', async () => { @@ -204,7 +206,9 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedDevBuildOptions)).code; - expect(builtContent).toContain(`signal("Hello World", { debugName: "testSignal" });`); + expect(cleanNewLines(builtContent)).toContain( + `signal( "Hello World", { debugName: "testSignal" } )`, + ); }); it('should insert debug info into signal function that already has custom options', async () => { @@ -224,7 +228,7 @@ runInEachFileSystem(() => { env.driveMain(); const jsContents = env.getContents('test.js'); - expect(jsContents).toContain( + expect(cleanNewLines(jsContents)).toContain( `signal('Hello World', { ...(ngDevMode ? { debugName: "testSignal" } : /* istanbul ignore next */ {}), equal: () => true })`, ); }); @@ -249,7 +253,7 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedProdBuildOptions)).code; - expect(builtContent).toContain(`signal("Hello World", { equal });`); + expect(cleanNewLines(builtContent)).toContain(`signal("Hello World", { equal })`); expect(builtContent).not.toContain('ngDevMode'); expect(builtContent).not.toContain('debugName'); }); @@ -276,8 +280,8 @@ runInEachFileSystem(() => { env.driveMain(); const jsContents = env.getContents('test.js'); - expect(jsContents).toContain( - `signal('Hello World', ...(ngDevMode ? [{ debugName: "testSignal" }] : /* istanbul ignore next */ [])`, + expect(cleanNewLines(jsContents)).toContain( + `signal('Hello World', /* @ts-ignore */ ...(ngDevMode ? [{ debugName: "testSignal" }] : /* istanbul ignore next */ [])`, ); }); @@ -303,7 +307,7 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedProdBuildOptions)).code; expect(builtContent).not.toContain('debugName'); - expect(builtContent).toContain('signal("Hello World")'); + expect(cleanNewLines(builtContent)).toContain('signal( "Hello World" )'); }); it('should not tree-shake away debug info if in dev mode', async () => { @@ -327,7 +331,9 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedDevBuildOptions)).code; - expect(builtContent).toContain(`signal("Hello World", { debugName: "testSignal" });`); + expect(cleanNewLines(builtContent)).toContain( + `signal( "Hello World", { debugName: "testSignal" } )`, + ); }); it('should insert debug info into signal function that already has custom options', async () => { @@ -350,7 +356,7 @@ runInEachFileSystem(() => { env.driveMain(); const jsContents = env.getContents('test.js'); - expect(jsContents).toContain( + expect(cleanNewLines(jsContents)).toContain( `signal('Hello World', { ...(ngDevMode ? { debugName: "testSignal" } : /* istanbul ignore next */ {}), equal: () => true })`, ); }); @@ -378,7 +384,7 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedProdBuildOptions)).code; - expect(builtContent).toContain(`signal("Hello World", { equal });`); + expect(cleanNewLines(builtContent)).toContain(`signal("Hello World", { equal });`); expect(builtContent).not.toContain('ngDevMode'); expect(builtContent).not.toContain('debugName'); }); @@ -410,8 +416,8 @@ runInEachFileSystem(() => { ); env.driveMain(); const jsContents = env.getContents('test.js'); - expect(jsContents).toContain( - `computed(() => testSignal(), ...(ngDevMode ? [{ debugName: "testComputed" }] : /* istanbul ignore next */ []))`, + expect(cleanNewLines(jsContents)).toContain( + `computed(() => testSignal(), /* @ts-ignore */ ...(ngDevMode ? [{ debugName: "testComputed" }] : /* istanbul ignore next */ []))`, ); }); @@ -429,7 +435,7 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedProdBuildOptions)).code; expect(builtContent).not.toContain('debugName'); - expect(builtContent).toContain('computed(() => testSignal())'); + expect(cleanNewLines(builtContent)).toContain('computed( () => testSignal() )'); }); it('should not tree-shake away debug info if in dev mode', async () => { @@ -444,8 +450,8 @@ runInEachFileSystem(() => { env.driveMain(); const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedDevBuildOptions)).code; - expect(builtContent).toContain( - `computed(() => testSignal(), { debugName: "testComputed" })`, + expect(cleanNewLines(builtContent)).toContain( + `computed( () => testSignal(), { debugName: "testComputed" } )`, ); }); @@ -461,7 +467,7 @@ runInEachFileSystem(() => { env.driveMain(); const jsContents = env.getContents('test.js'); - expect(jsContents).toContain( + expect(cleanNewLines(jsContents)).toContain( `computed(() => testSignal(), { ...(ngDevMode ? { debugName: "testComputed" } : /* istanbul ignore next */ {}), equal: () => true })`, ); }); @@ -481,7 +487,9 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedProdBuildOptions)).code; - expect(builtContent).toContain(`testComputed = computed(() => testSignal(), { equal })`); + expect(cleanNewLines(builtContent)).toContain( + `testComputed = computed(() => testSignal(), { equal })`, + ); expect(builtContent).not.toContain('ngDevMode'); expect(builtContent).not.toContain('debugName'); }); @@ -501,8 +509,8 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedDevBuildOptions)).code; - expect(builtContent).toContain( - `testComputed = computed(() => testSignal(), { debugName: "testComputed", equal });`, + expect(cleanNewLines(builtContent)).toContain( + `testComputed = computed(() => testSignal(), { debugName: "testComputed", equal })`, ); }); }); @@ -526,7 +534,7 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedProdBuildOptions)).code; expect(builtContent).not.toContain('debugName'); - expect(builtContent).toContain('computed(() => this.testSignal())'); + expect(cleanNewLines(builtContent)).toContain('computed( () => this.testSignal() )'); }); it('should not tree-shake away debug info if in dev mode', async () => { @@ -546,8 +554,8 @@ runInEachFileSystem(() => { env.driveMain(); const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedDevBuildOptions)).code; - expect(builtContent).toContain( - `computed(() => this.testSignal(), { debugName: "testComputed" })`, + expect(cleanNewLines(builtContent)).toContain( + `computed( () => this.testSignal(), { debugName: "testComputed" } )`, ); }); @@ -568,7 +576,7 @@ runInEachFileSystem(() => { env.driveMain(); const jsContents = env.getContents('test.js'); - expect(jsContents).toContain( + expect(cleanNewLines(jsContents)).toContain( `computed(() => this.testSignal(), { ...(ngDevMode ? { debugName: "testComputed" } : /* istanbul ignore next */ {}), equal: () => true })`, ); }); @@ -593,7 +601,9 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedProdBuildOptions)).code; - expect(builtContent).toContain(`computed(() => this.testSignal(), { equal })`); + expect(cleanNewLines(builtContent)).toContain( + `computed(() => this.testSignal(), { equal })`, + ); expect(builtContent).not.toContain('ngDevMode'); expect(builtContent).not.toContain('debugName'); }); @@ -617,8 +627,8 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedDevBuildOptions)).code; - expect(builtContent).toContain( - `computed(() => this.testSignal(), { debugName: "testComputed", equal });`, + expect(cleanNewLines(builtContent)).toContain( + `computed(() => this.testSignal(), { debugName: "testComputed", equal })`, ); }); }); @@ -648,7 +658,7 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedProdBuildOptions)).code; expect(builtContent).not.toContain('debugName'); - expect(builtContent).toContain('computed(() => this.testSignal())'); + expect(cleanNewLines(builtContent)).toContain('computed( () => this.testSignal() )'); }); it('should not tree-shake away debug info if in dev mode', async () => { @@ -674,8 +684,8 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedDevBuildOptions)).code; - expect(builtContent).toContain( - `computed(() => this.testSignal(), { debugName: "testComputed" })`, + expect(cleanNewLines(builtContent)).toContain( + `computed( () => this.testSignal(), { debugName: "testComputed" } )`, ); }); @@ -700,7 +710,7 @@ runInEachFileSystem(() => { env.driveMain(); const jsContents = env.getContents('test.js'); - expect(jsContents).toContain( + expect(cleanNewLines(jsContents)).toContain( `computed(() => this.testSignal(), { ...(ngDevMode ? { debugName: "testComputed" } : /* istanbul ignore next */ {}), equal: () => true })`, ); }); @@ -728,7 +738,9 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedProdBuildOptions)).code; - expect(builtContent).toContain(`computed(() => this.testSignal(), { equal })`); + expect(cleanNewLines(builtContent)).toContain( + `computed(() => this.testSignal(), { equal })`, + ); expect(builtContent).not.toContain('ngDevMode'); expect(builtContent).not.toContain('debugName'); }); @@ -756,8 +768,8 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedDevBuildOptions)).code; - expect(builtContent).toContain( - `computed(() => this.testSignal(), { debugName: "testComputed", equal });`, + expect(cleanNewLines(builtContent)).toContain( + `computed(() => this.testSignal(), { debugName: "testComputed", equal })`, ); }); }); @@ -799,11 +811,11 @@ runInEachFileSystem(() => { ); env.driveMain(); const jsContents = env.getContents('test.js'); - expect(jsContents).toContain( - `model('Hello World', ...(ngDevMode ? [{ debugName: "testModel" }] : /* istanbul ignore next */ [])`, + expect(cleanNewLines(jsContents)).toContain( + `model('Hello World', /* @ts-ignore */ ...(ngDevMode ? [{ debugName: "testModel" }] : /* istanbul ignore next */ []))`, ); - expect(jsContents).toContain( - `model(...(ngDevMode ? [undefined, { debugName: "testModel2" }] : /* istanbul ignore next */ [])`, + expect(cleanNewLines(jsContents)).toContain( + `model(/* @ts-ignore */ ...(ngDevMode ? [undefined, { debugName: "testModel2" }] : /* istanbul ignore next */ []))`, ); }); @@ -824,7 +836,7 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedProdBuildOptions)).code; expect(builtContent).not.toContain('debugName'); - expect(builtContent).toContain('model("Hello World")'); + expect(cleanNewLines(builtContent)).toContain('model( "Hello World" )'); }); describe('.required', () => { @@ -844,8 +856,8 @@ runInEachFileSystem(() => { env.driveMain(); const jsContents = env.getContents('test.js'); - expect(jsContents).toContain( - `model.required(...(ngDevMode ? [{ debugName: "testModel" }] : /* istanbul ignore next */ [])`, + expect(cleanNewLines(jsContents)).toContain( + `model.required(/* @ts-ignore */ ...(ngDevMode ? [{ debugName: "testModel" }] : /* istanbul ignore next */ []))`, ); }); @@ -865,7 +877,7 @@ runInEachFileSystem(() => { env.driveMain(); const jsContents = env.getContents('test.js'); - expect(jsContents).toContain( + expect(cleanNewLines(jsContents)).toContain( `model.required({ ...(ngDevMode ? { debugName: "testModel" } : /* istanbul ignore next */ {}), alias: 'testModelAlias' })`, ); }); @@ -906,7 +918,9 @@ runInEachFileSystem(() => { env.driveMain(); const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedDevBuildOptions)).code; - expect(builtContent).toContain(`model.required({ debugName: "testModel" });`); + expect(cleanNewLines(builtContent)).toContain( + `model.required( { debugName: "testModel" } )`, + ); }); it('should tree-shake away debug info if in prod mode with custom options', async () => { @@ -945,8 +959,8 @@ runInEachFileSystem(() => { env.driveMain(); const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedDevBuildOptions)).code; - expect(builtContent).toContain( - `model.required({ debugName: "testModel", alias: "testModelAlias" });`, + expect(cleanNewLines(builtContent)).toContain( + `model.required({ debugName: "testModel", alias: "testModelAlias" })`, ); }); }); @@ -989,8 +1003,8 @@ runInEachFileSystem(() => { env.driveMain(); const jsContents = env.getContents('test.js'); - expect(jsContents).toContain( - `input(...(ngDevMode ? [undefined, { debugName: "testInput" }] : /* istanbul ignore next */ [])`, + expect(cleanNewLines(jsContents)).toContain( + `input(/* @ts-ignore */ ...(ngDevMode ? [undefined, { debugName: "testInput" }] : /* istanbul ignore next */ []))`, ); }); @@ -1032,8 +1046,8 @@ runInEachFileSystem(() => { env.driveMain(); const jsContents = env.getContents('test.js'); - expect(jsContents).toContain( - `input.required(...(ngDevMode ? [{ debugName: "testInput" }] : /* istanbul ignore next */ []))`, + expect(cleanNewLines(jsContents)).toContain( + `input.required(/* @ts-ignore */ ...(ngDevMode ? [{ debugName: "testInput" }] : /* istanbul ignore next */ []))`, ); }); @@ -1053,7 +1067,7 @@ runInEachFileSystem(() => { env.driveMain(); const jsContents = env.getContents('test.js'); - expect(jsContents).toContain( + expect(cleanNewLines(jsContents)).toContain( `input.required({ ...(ngDevMode ? { debugName: "testInput" } : /* istanbul ignore next */ {}), alias: 'testInputAlias' })`, ); }); @@ -1096,7 +1110,9 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedDevBuildOptions)).code; - expect(builtContent).toContain(`input.required({ debugName: "testInput" });`); + expect(cleanNewLines(builtContent)).toContain( + `input.required( { debugName: "testInput" } )`, + ); }); it('should tree-shake away debug info if in prod mode with custom options', async () => { @@ -1137,8 +1153,8 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedDevBuildOptions)).code; - expect(builtContent).toContain( - `input.required({ debugName: "testInput", alias: "testInputAlias" });`, + expect(cleanNewLines(builtContent)).toContain( + `input.required({ debugName: "testInput", alias: "testInputAlias" })`, ); }); }); @@ -1190,11 +1206,11 @@ runInEachFileSystem(() => { env.driveMain(); const jsContents = env.getContents('test.js'); - expect(jsContents).toContain( - `viewChild('foo', ...(ngDevMode ? [{ debugName: "testViewChild" }] : /* istanbul ignore next */ [])`, + expect(cleanNewLines(jsContents)).toContain( + `viewChild('foo', /* @ts-ignore */ ...(ngDevMode ? [{ debugName: "testViewChild" }] : /* istanbul ignore next */ []))`, ); - expect(jsContents).toContain( - `viewChild(ChildComponent, ...(ngDevMode ? [{ debugName: "testViewChildComponent" }] : /* istanbul ignore next */ [])`, + expect(cleanNewLines(jsContents)).toContain( + `viewChild(ChildComponent, /* @ts-ignore */ ...(ngDevMode ? [{ debugName: "testViewChildComponent" }] : /* istanbul ignore next */ []))`, ); }); @@ -1224,8 +1240,8 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedProdBuildOptions)).code; expect(builtContent).not.toContain('debugName'); - expect(builtContent).toContain(`viewChild("foo")`); - expect(builtContent).toContain(`viewChild(ChildComponent)`); + expect(cleanNewLines(builtContent)).toContain(`viewChild( "foo" )`); + expect(cleanNewLines(builtContent)).toContain(`viewChild( ChildComponent )`); }); it('should not tree-shake away debug info if in dev mode', async () => { @@ -1253,9 +1269,11 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedDevBuildOptions)).code; - expect(builtContent).toContain(`viewChild("foo", { debugName: "testViewChild" })`); - expect(builtContent).toContain( - `viewChild(ChildComponent, { debugName: "testViewChildComponent" })`, + expect(cleanNewLines(builtContent)).toContain( + `viewChild( "foo", { debugName: "testViewChild" } )`, + ); + expect(cleanNewLines(builtContent)).toContain( + `viewChild( ChildComponent, { debugName: "testViewChildComponent" } )`, ); }); @@ -1297,7 +1315,7 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedDevBuildOptions)).code; - expect(builtContent).toContain( + expect(cleanNewLines(builtContent)).toContain( `viewChild("foo", { debugName: "testViewChild", read: ElementRef })`, ); }); @@ -1339,8 +1357,8 @@ runInEachFileSystem(() => { env.driveMain(); const jsContents = env.getContents('test.js'); - expect(jsContents).toContain( - `viewChildren('foo', ...(ngDevMode ? [{ debugName: "testViewChildren" }] : /* istanbul ignore next */ [])`, + expect(cleanNewLines(jsContents)).toContain( + `viewChildren('foo', /* @ts-ignore */ ...(ngDevMode ? [{ debugName: "testViewChildren" }] : /* istanbul ignore next */ []))`, ); }); @@ -1362,7 +1380,7 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedProdBuildOptions)).code; expect(builtContent).not.toContain('debugName'); - expect(builtContent).toContain('viewChildren("foo")'); + expect(cleanNewLines(builtContent)).toContain('viewChildren( "foo" )'); }); it('should not tree-shake away debug info if in dev mode', async () => { @@ -1382,7 +1400,9 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedDevBuildOptions)).code; - expect(builtContent).toContain(`viewChildren("foo", { debugName: "testViewChildren" })`); + expect(cleanNewLines(builtContent)).toContain( + `viewChildren( "foo", { debugName: "testViewChildren" } )`, + ); }); it('should tree-shake away debug info if in prod mode with existing options', async () => { @@ -1403,7 +1423,7 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedProdBuildOptions)).code; expect(builtContent).not.toContain('debugName'); - expect(builtContent).toContain('viewChildren("foo", { read: ElementRef })'); + expect(cleanNewLines(builtContent)).toContain('viewChildren("foo", { read: ElementRef })'); }); it('should not tree-shake away debug info if in dev mode with existing options', async () => { @@ -1423,7 +1443,7 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedDevBuildOptions)).code; - expect(builtContent).toContain( + expect(cleanNewLines(builtContent)).toContain( `viewChildren("foo", { debugName: "testViewChild", read: ElementRef })`, ); }); @@ -1465,8 +1485,8 @@ runInEachFileSystem(() => { env.driveMain(); const jsContents = env.getContents('test.js'); - expect(jsContents).toContain( - `contentChild('foo', ...(ngDevMode ? [{ debugName: "testContentChild" }] : /* istanbul ignore next */ [])`, + expect(cleanNewLines(jsContents)).toContain( + `contentChild('foo', /* @ts-ignore */ ...(ngDevMode ? [{ debugName: "testContentChild" }] : /* istanbul ignore next */ []))`, ); }); @@ -1488,7 +1508,7 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedProdBuildOptions)).code; expect(builtContent).not.toContain('debugName'); - expect(builtContent).toContain('contentChild("foo")'); + expect(cleanNewLines(builtContent)).toContain('contentChild( "foo" )'); }); it('should not tree-shake away debug info if in dev mode', async () => { @@ -1508,7 +1528,9 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedDevBuildOptions)).code; - expect(builtContent).toContain(`contentChild("foo", { debugName: "testContentChild" })`); + expect(cleanNewLines(builtContent)).toContain( + `contentChild( "foo", { debugName: "testContentChild" } )`, + ); }); it('should tree-shake away debug info if in prod mode with existing options', async () => { @@ -1529,7 +1551,7 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedProdBuildOptions)).code; expect(builtContent).not.toContain('debugName'); - expect(builtContent).toContain('contentChild("foo", { read: ElementRef })'); + expect(cleanNewLines(builtContent)).toContain('contentChild("foo", { read: ElementRef })'); }); it('should not tree-shake away debug info if in dev mode with existing options', async () => { @@ -1549,7 +1571,7 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedDevBuildOptions)).code; - expect(builtContent).toContain( + expect(cleanNewLines(builtContent)).toContain( `contentChild("foo", { debugName: "testContentChild", read: ElementRef })`, ); }); @@ -1593,8 +1615,8 @@ runInEachFileSystem(() => { env.driveMain(); const jsContents = env.getContents('test.js'); - expect(jsContents).toContain( - `contentChildren('foo', ...(ngDevMode ? [{ debugName: "testContentChildren" }] : /* istanbul ignore next */ [])`, + expect(cleanNewLines(jsContents)).toContain( + `contentChildren('foo', /* @ts-ignore */ ...(ngDevMode ? [{ debugName: "testContentChildren" }] : /* istanbul ignore next */ []))`, ); }); @@ -1616,7 +1638,7 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedProdBuildOptions)).code; expect(builtContent).not.toContain('debugName'); - expect(builtContent).toContain('contentChildren("foo")'); + expect(cleanNewLines(builtContent)).toContain('contentChildren( "foo" )'); }); it('should not tree-shake away debug info if in dev mode', async () => { @@ -1636,8 +1658,8 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedDevBuildOptions)).code; - expect(builtContent).toContain( - `contentChildren("foo", { debugName: "testContentChildren" })`, + expect(cleanNewLines(builtContent)).toContain( + `contentChildren( "foo", { debugName: "testContentChildren" } )`, ); }); @@ -1659,7 +1681,9 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedProdBuildOptions)).code; expect(builtContent).not.toContain('debugName'); - expect(builtContent).toContain('contentChildren("foo", { read: ElementRef })'); + expect(cleanNewLines(builtContent)).toContain( + 'contentChildren("foo", { read: ElementRef })', + ); }); it('should not tree-shake away debug info if in dev mode with existing options', async () => { @@ -1679,7 +1703,7 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedDevBuildOptions)).code; - expect(builtContent).toContain( + expect(cleanNewLines(builtContent)).toContain( `contentChildren("foo", { debugName: "testContentChildren", read: ElementRef })`, ); }); @@ -1723,8 +1747,8 @@ runInEachFileSystem(() => { ); env.driveMain(); const jsContents = env.getContents('test.js'); - expect(jsContents).toContain( - `effect(() => this.testSignal(), ...(ngDevMode ? [{ debugName: "testEffect" }] : /* istanbul ignore next */ [])`, + expect(cleanNewLines(jsContents)).toContain( + `effect(() => this.testSignal(), /* @ts-ignore */ ...(ngDevMode ? [{ debugName: "testEffect" }] : /* istanbul ignore next */ []))`, ); }); @@ -1745,7 +1769,7 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedProdBuildOptions)).code; expect(builtContent).not.toContain('debugName'); - expect(builtContent).toContain('effect(() => this.testSignal())'); + expect(cleanNewLines(builtContent)).toContain('effect( () => this.testSignal() )'); }); it('should not tree-shake away debug info if in dev mode', async () => { @@ -1766,8 +1790,8 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedDevBuildOptions)).code; - expect(builtContent).toContain( - `effect(() => this.testSignal(), { debugName: "testEffect" })`, + expect(cleanNewLines(builtContent)).toContain( + `effect( () => this.testSignal(), { debugName: "testEffect" } )`, ); }); @@ -1790,7 +1814,7 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedProdBuildOptions)).code; expect(builtContent).not.toContain('debugName'); - expect(builtContent).toContain( + expect(cleanNewLines(builtContent)).toContain( 'effect(() => this.testSignal(), { manualCleanup: !0, allowSignalWrites: !0 })', ); }); @@ -1813,7 +1837,7 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedDevBuildOptions)).code; - expect(builtContent).toContain( + expect(cleanNewLines(builtContent)).toContain( `effect(() => this.testSignal(), { debugName: "testEffect", manualCleanup: !0, allowSignalWrites: !0 })`, ); }); @@ -1844,8 +1868,8 @@ runInEachFileSystem(() => { ); env.driveMain(); const jsContents = env.getContents('test.js'); - expect(jsContents).toContain( - `linkedSignal(() => testSignal(), ...(ngDevMode ? [{ debugName: "testLinkedSignal" }] : /* istanbul ignore next */ [])`, + expect(cleanNewLines(jsContents)).toContain( + `linkedSignal(() => testSignal(), /* @ts-ignore */ ...(ngDevMode ? [{ debugName: "testLinkedSignal" }] : /* istanbul ignore next */ []))`, ); }); @@ -1863,7 +1887,7 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedProdBuildOptions)).code; expect(builtContent).not.toContain('debugName'); - expect(builtContent).toContain('linkedSignal(() => testSignal())'); + expect(cleanNewLines(builtContent)).toContain('linkedSignal( () => testSignal() )'); }); it('should not tree-shake away debug info if in dev mode', async () => { @@ -1878,8 +1902,8 @@ runInEachFileSystem(() => { env.driveMain(); const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedDevBuildOptions)).code; - expect(builtContent).toContain( - `linkedSignal(() => testSignal(), { debugName: "testLinkedSignal" })`, + expect(cleanNewLines(builtContent)).toContain( + `linkedSignal( () => testSignal(), { debugName: "testLinkedSignal" } )`, ); }); @@ -1895,7 +1919,7 @@ runInEachFileSystem(() => { env.driveMain(); const jsContents = env.getContents('test.js'); - expect(jsContents).toContain( + expect(cleanNewLines(jsContents)).toContain( `linkedSignal(() => testSignal(), { ...(ngDevMode ? { debugName: "testLinkedSignal" } : /* istanbul ignore next */ {}), equal: () => true })`, ); }); @@ -1915,7 +1939,7 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedProdBuildOptions)).code; - expect(builtContent).toContain( + expect(cleanNewLines(builtContent)).toContain( `testLinkedSignal = linkedSignal(() => testSignal(), { equal })`, ); expect(builtContent).not.toContain('ngDevMode'); @@ -1937,7 +1961,7 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedDevBuildOptions)).code; - expect(builtContent).toContain( + expect(cleanNewLines(builtContent)).toContain( `testLinkedSignal = linkedSignal(() => testSignal(), { debugName: "testLinkedSignal", equal });`, ); }); @@ -2039,7 +2063,7 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedProdBuildOptions)).code; expect(builtContent).not.toContain('debugName'); - expect(builtContent).toContain('linkedSignal(() => this.testSignal())'); + expect(cleanNewLines(builtContent)).toContain('linkedSignal( () => this.testSignal() )'); }); it('should not tree-shake away debug info if in dev mode', async () => { @@ -2059,8 +2083,8 @@ runInEachFileSystem(() => { env.driveMain(); const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedDevBuildOptions)).code; - expect(builtContent).toContain( - `linkedSignal(() => this.testSignal(), { debugName: "testLinkedSignal" })`, + expect(cleanNewLines(builtContent)).toContain( + `linkedSignal( () => this.testSignal(), { debugName: "testLinkedSignal" } )`, ); }); @@ -2081,7 +2105,7 @@ runInEachFileSystem(() => { env.driveMain(); const jsContents = env.getContents('test.js'); - expect(jsContents).toContain( + expect(cleanNewLines(jsContents)).toContain( `linkedSignal(() => this.testSignal(), { ...(ngDevMode ? { debugName: "testLinkedSignal" } : /* istanbul ignore next */ {}), equal: () => true })`, ); }); @@ -2131,7 +2155,7 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedDevBuildOptions)).code; - expect(builtContent).toContain( + expect(cleanNewLines(builtContent)).toContain( `this.testLinkedSignal = linkedSignal(() => this.testSignal(), { debugName: "testLinkedSignal", equal });`, ); }); @@ -2251,7 +2275,7 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedProdBuildOptions)).code; expect(builtContent).not.toContain('debugName'); - expect(builtContent).toContain('linkedSignal(() => this.testSignal())'); + expect(cleanNewLines(builtContent)).toContain('linkedSignal( () => this.testSignal() )'); }); it('should not tree-shake away debug info if in dev mode', async () => { @@ -2276,8 +2300,8 @@ runInEachFileSystem(() => { env.driveMain(); const jsContents = env.getContents('test.js'); const builtContent = (await esbuild.transform(jsContents, minifiedDevBuildOptions)).code; - expect(builtContent).toContain( - `linkedSignal(() => this.testSignal(), { debugName: "testLinkedSignal" })`, + expect(cleanNewLines(builtContent)).toContain( + `linkedSignal( () => this.testSignal(), { debugName: "testLinkedSignal" } )`, ); }); @@ -2303,7 +2327,7 @@ runInEachFileSystem(() => { env.driveMain(); const jsContents = env.getContents('test.js'); - expect(jsContents).toContain( + expect(cleanNewLines(jsContents)).toContain( `linkedSignal(() => this.testSignal(), { ...(ngDevMode ? { debugName: "testLinkedSignal" } : /* istanbul ignore next */ {}), equal: () => true })`, ); }); @@ -2775,9 +2799,9 @@ runInEachFileSystem(() => { `, ); env.driveMain(); - const jsContents = cleanNewLines(env.getContents('test.js')); - expect(jsContents).toContain( - `httpResource(() => '/api', ...(ngDevMode ? [{ debugName: "testHttpResource" }] : /* istanbul ignore next */ []))`, + const jsContents = env.getContents('test.js'); + expect(cleanNewLines(jsContents)).toContain( + `httpResource(() => '/api', /* @ts-ignore */ ...(ngDevMode ? [{ debugName: "testHttpResource" }] : /* istanbul ignore next */ []))`, ); }); @@ -2796,7 +2820,7 @@ runInEachFileSystem(() => { const builtContent = (await esbuild.transform(jsContents, minifiedProdBuildOptions)).code; const contentWoNewLines = cleanNewLines(builtContent); expect(contentWoNewLines).not.toContain('debugName'); - expect(contentWoNewLines).toContain(`testHttpResource = httpResource(() => "/api")`); + expect(contentWoNewLines).toContain(`testHttpResource = httpResource( () => "/api" )`); }); it('should not tree-shake away debug info if in dev mode', async () => { @@ -2813,9 +2837,7 @@ runInEachFileSystem(() => { const builtContent = (await esbuild.transform(jsContents, minifiedDevBuildOptions)).code; const contentWoNewLines = cleanNewLines(builtContent); expect(contentWoNewLines).toContain( - 'testHttpResource = httpResource(() => "/api", { ' + - 'debugName: "testHttpResource" ' + - '})', + 'testHttpResource = httpResource( () => "/api", { debugName: "testHttpResource" } )', ); }); }); @@ -2837,7 +2859,7 @@ runInEachFileSystem(() => { env.driveMain(); const jsContents = cleanNewLines(env.getContents('test.js')); expect(jsContents).toContain( - `httpResource(() => '/api', ...(ngDevMode ? [{ debugName: "testHttpResource" }] : /* istanbul ignore next */ []))`, + `httpResource(() => '/api', /* @ts-ignore */ ...(ngDevMode ? [{ debugName: "testHttpResource" }] : /* istanbul ignore next */ []))`, ); }); @@ -2860,7 +2882,7 @@ runInEachFileSystem(() => { const builtContent = (await esbuild.transform(jsContents, minifiedProdBuildOptions)).code; const contentWoNewLines = cleanNewLines(builtContent); expect(contentWoNewLines).not.toContain('debugName'); - expect(contentWoNewLines).toContain(`testHttpResource = httpResource(() => "/api")`); + expect(contentWoNewLines).toContain(`testHttpResource = httpResource( () => "/api" )`); }); it('should not tree-shake away debug info if in dev mode', async () => { @@ -2882,9 +2904,7 @@ runInEachFileSystem(() => { const builtContent = (await esbuild.transform(jsContents, minifiedDevBuildOptions)).code; const contentWoNewLines = cleanNewLines(builtContent); expect(contentWoNewLines).toContain( - 'testHttpResource = httpResource(() => "/api", { ' + - 'debugName: "testHttpResource" ' + - '})', + 'testHttpResource = httpResource( () => "/api", { debugName: "testHttpResource" } )', ); }); }); @@ -2909,7 +2929,7 @@ runInEachFileSystem(() => { env.driveMain(); const jsContents = cleanNewLines(env.getContents('test.js')); expect(jsContents).toContain( - `httpResource(() => '/api', ...(ngDevMode ? [{ debugName: "testHttpResource" }] : /* istanbul ignore next */ []))`, + `httpResource(() => '/api', /* @ts-ignore */ ...(ngDevMode ? [{ debugName: "testHttpResource" }] : /* istanbul ignore next */ []))`, ); }); @@ -2935,7 +2955,7 @@ runInEachFileSystem(() => { const builtContent = (await esbuild.transform(jsContents, minifiedProdBuildOptions)).code; const contentWoNewLines = cleanNewLines(builtContent); expect(contentWoNewLines).not.toContain('debugName'); - expect(contentWoNewLines).toContain(`testHttpResource = httpResource(() => "/api")`); + expect(contentWoNewLines).toContain(`testHttpResource = httpResource( () => "/api" )`); }); it('should not tree-shake away debug info if in dev mode', async () => { @@ -2960,9 +2980,7 @@ runInEachFileSystem(() => { const builtContent = (await esbuild.transform(jsContents, minifiedDevBuildOptions)).code; const contentWoNewLines = cleanNewLines(builtContent); expect(contentWoNewLines).toContain( - 'testHttpResource = httpResource(() => "/api", { ' + - 'debugName: "testHttpResource" ' + - '})', + 'testHttpResource = httpResource( () => "/api", { debugName: "testHttpResource" } )', ); }); }); diff --git a/packages/compiler-cli/test/ngtsc/defer_spec.ts b/packages/compiler-cli/test/ngtsc/defer_spec.ts index 07398f1d0c92..08f146695c19 100644 --- a/packages/compiler-cli/test/ngtsc/defer_spec.ts +++ b/packages/compiler-cli/test/ngtsc/defer_spec.ts @@ -15,6 +15,10 @@ import {NgtscTestEnvironment} from './env'; const testFiles = loadStandardTestFiles(); +function cleanNewLines(contents: string) { + return contents.replace(/\n/g, ' ').replace(/\s+/g, ' '); +} + runInEachFileSystem(() => { describe('ngtsc @defer block', () => { let env!: NgtscTestEnvironment; @@ -69,7 +73,9 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); expect(jsContents).toContain('ɵɵdefer(1, 0, TestCmp_Defer_1_DepsFn)'); - expect(jsContents).toContain('() => [import("./cmp-a").then(m => m.CmpA), LocalDep]'); + expect(cleanNewLines(jsContents)).toContain( + '() => [/* @ts-ignore */ import("./cmp-a").then(m => m.CmpA), LocalDep]', + ); // The `CmpA` symbol wasn't referenced elsewhere, so it can be defer-loaded // via dynamic imports and an original import can be removed. @@ -278,10 +284,8 @@ runInEachFileSystem(() => { // Both `CmpA` and `CmpB` were used inside the defer block and were not // referenced elsewhere, so we generate dynamic imports and drop a regular one. - expect(jsContents).toContain( - '() => [' + - 'import("./cmp-a").then(m => m.CmpA), ' + - 'import("./cmp-a").then(m => m.CmpB)]', + expect(cleanNewLines(jsContents)).toContain( + '() => [/* @ts-ignore */ import("./cmp-a").then(m => m.CmpA), /* @ts-ignore */ import("./cmp-a").then(m => m.CmpB)]', ); expect(jsContents).not.toContain('import { CmpA, CmpB }'); }); @@ -324,7 +328,9 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); expect(jsContents).toContain('ɵɵdefer(1, 0, TestCmp_Defer_1_DepsFn)'); - expect(jsContents).toContain('() => [import("./cmp-a").then(m => m.CmpA)]'); + expect(cleanNewLines(jsContents)).toContain( + '() => [/* @ts-ignore */ import("./cmp-a").then(m => m.CmpA)]', + ); // The `CmpA` symbol wasn't referenced elsewhere, so it can be defer-loaded // via dynamic imports and an original import can be removed. @@ -373,7 +379,9 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); expect(jsContents).toContain('ɵɵdefer(1, 0, TestCmp_Defer_1_DepsFn)'); - expect(jsContents).toContain('() => [import("./cmp-a").then(m => m.CmpA)]'); + expect(cleanNewLines(jsContents)).toContain( + '() => [/* @ts-ignore */ import("./cmp-a").then(m => m.CmpA)]', + ); expect(jsContents).not.toContain('import { CmpA }'); }); @@ -420,7 +428,9 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); expect(jsContents).toContain('ɵɵdefer(1, 0, TestCmp_Defer_1_DepsFn)'); - expect(jsContents).toContain('() => [import("./cmp-a").then(m => m.CmpA)]'); + expect(cleanNewLines(jsContents)).toContain( + '() => [/* @ts-ignore */ import("./cmp-a").then(m => m.CmpA)]', + ); expect(jsContents).not.toContain('import { CmpA }'); }); @@ -467,7 +477,9 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); expect(jsContents).toContain('ɵɵdefer(1, 0, TestCmp_Defer_1_DepsFn)'); - expect(jsContents).toContain('() => [import("./cmp-a").then(m => m.CmpA)]'); + expect(cleanNewLines(jsContents)).toContain( + '() => [/* @ts-ignore */ import("./cmp-a").then(m => m.CmpA)]', + ); expect(jsContents).not.toContain('import { CmpA }'); }); @@ -514,7 +526,9 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); expect(jsContents).toContain('ɵɵdefer(1, 0, TestCmp_Defer_1_DepsFn)'); - expect(jsContents).toContain('() => [import("./cmp-a").then(m => m.CmpA)]'); + expect(cleanNewLines(jsContents)).toContain( + '() => [/* @ts-ignore */ import("./cmp-a").then(m => m.CmpA)]', + ); expect(jsContents).not.toContain('import { CmpA }'); }); @@ -564,8 +578,8 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); expect(jsContents).toContain('ɵɵdefer(1, 0, TestCmp_Defer_1_DepsFn)'); - expect(jsContents).toContain( - '() => [import("./cmps").then(m => m.CmpA), import("./cmps").then(m => m.CmpB)]', + expect(cleanNewLines(jsContents)).toContain( + '() => [/* @ts-ignore */ import("./cmps").then(m => m.CmpA), /* @ts-ignore */ import("./cmps").then(m => m.CmpB)]', ); expect(jsContents).not.toContain('import { CmpA }'); expect(jsContents).not.toContain('import { CmpB }'); @@ -610,11 +624,11 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); expect(jsContents).toContain('ɵɵdefer(1, 0, TestCmp_Defer_1_DepsFn)'); - expect(jsContents).toContain( - 'const TestCmp_Defer_1_DepsFn = () => [import("./cmp-a").then(m => m.default), LocalDep];', + expect(cleanNewLines(jsContents)).toContain( + 'const TestCmp_Defer_1_DepsFn = () => [/* @ts-ignore */ import("./cmp-a").then(m => m.default), LocalDep];', ); - expect(jsContents).toContain( - 'i0.ɵsetClassMetadataAsync(TestCmp, () => [import("./cmp-a").then(m => m.default)]', + expect(cleanNewLines(jsContents)).toContain( + 'i0.ɵsetClassMetadataAsync(TestCmp, () => [/* @ts-ignore */ import("./cmp-a").then(m => m.default)]', ); // The `CmpA` symbol wasn't referenced elsewhere, so it can be defer-loaded // via dynamic imports and an original import can be removed. @@ -673,7 +687,7 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); expect(jsContents).toContain('ɵɵdefer(1, 0, TestCmp_Defer_1_DepsFn)'); - expect(jsContents).toContain('() => [import("./cmp").then(m => m.Cmp)]'); + expect(cleanNewLines(jsContents)).toContain('() => [/* @ts-ignore */ import("./cmp").then(m => m.Cmp)]'); expect(jsContents).not.toContain('import { Cmp }'); }); @@ -918,13 +932,13 @@ runInEachFileSystem(() => { // Expect that all deferrableImports in local compilation mode // are located in a single function (since we can't detect in // the local mode which components belong to which block). - expect(jsContents).toContain( - 'const AppCmp_For_1_Conditional_0_Defer_1_DepsFn = () => [' + - 'import("./deferred-a").then(m => m.DeferredCmpA), ' + + expect(cleanNewLines(jsContents)).toContain( + 'const AppCmp_For_1_Conditional_0_Defer_1_DepsFn = () => [/* @ts-ignore */ ' + + 'import("./deferred-a").then(m => m.DeferredCmpA), /* @ts-ignore */ ' + 'import("./pipe-a").then(m => m.PipeA)];', ); - expect(jsContents).toContain( - 'const AppCmp_For_1_Conditional_0_Defer_4_DepsFn = () => [' + + expect(cleanNewLines(jsContents)).toContain( + 'const AppCmp_For_1_Conditional_0_Defer_4_DepsFn = () => [/* @ts-ignore */ ' + 'import("./deferred-b").then(m => m.DeferredCmpB)];', ); @@ -938,10 +952,10 @@ runInEachFileSystem(() => { expect(jsContents).toContain('ɵɵdefer(4, 3, AppCmp_For_1_Conditional_0_Defer_4_DepsFn);'); // Expect `ɵsetClassMetadataAsync` to contain dynamic imports too. - expect(jsContents).toContain( - 'ɵsetClassMetadataAsync(AppCmp, () => [' + - 'import("./deferred-a").then(m => m.DeferredCmpA), ' + - 'import("./pipe-a").then(m => m.PipeA), ' + + expect(cleanNewLines(jsContents)).toContain( + 'ɵsetClassMetadataAsync(AppCmp, () => [/* @ts-ignore */ ' + + 'import("./deferred-a").then(m => m.DeferredCmpA), /* @ts-ignore */ ' + + 'import("./pipe-a").then(m => m.PipeA), /* @ts-ignore */ ' + 'import("./deferred-b").then(m => m.DeferredCmpB)], ' + '(DeferredCmpA, PipeA, DeferredCmpB) => {', ); @@ -1023,15 +1037,13 @@ runInEachFileSystem(() => { // Expect that all deferrableImports to become dynamic imports. // Other imported symbols remain eager. - expect(jsContents).toContain( - 'const AppCmp_Defer_1_DepsFn = () => [' + - 'import("./deferred-a").then(m => m.DeferredCmpA), ' + - 'EagerCmpA];', + expect(cleanNewLines(jsContents)).toContain( + 'const AppCmp_Defer_1_DepsFn = () => [/* @ts-ignore */ ' + + 'import("./deferred-a").then(m => m.DeferredCmpA), EagerCmpA];', ); - expect(jsContents).toContain( - 'const AppCmp_Defer_4_DepsFn = () => [' + - 'import("./deferred-b").then(m => m.DeferredCmpB), ' + - 'EagerCmpA];', + expect(cleanNewLines(jsContents)).toContain( + 'const AppCmp_Defer_4_DepsFn = () => [/* @ts-ignore */ ' + + 'import("./deferred-b").then(m => m.DeferredCmpB), EagerCmpA];', ); // Make sure there are no eager imports present in the output. @@ -1046,9 +1058,9 @@ runInEachFileSystem(() => { expect(jsContents).toContain('ɵɵdefer(4, 3, AppCmp_Defer_4_DepsFn);'); // Expect `ɵsetClassMetadataAsync` to contain dynamic imports too. - expect(jsContents).toContain( - 'ɵsetClassMetadataAsync(AppCmp, () => [' + - 'import("./deferred-a").then(m => m.DeferredCmpA), ' + + expect(cleanNewLines(jsContents)).toContain( + 'ɵsetClassMetadataAsync(AppCmp, () => [/* @ts-ignore */ ' + + 'import("./deferred-a").then(m => m.DeferredCmpA), /* @ts-ignore */ ' + 'import("./deferred-b").then(m => m.DeferredCmpB)], ' + '(DeferredCmpA, DeferredCmpB) => {', ); @@ -1379,14 +1391,10 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); expect(jsContents).toContain('ɵɵdefer(1, 0, TestCmp_Defer_1_DepsFn)'); - expect(jsContents).toContain( - // ngDevMode check is present + expect(cleanNewLines(jsContents)).toContain( '(() => { (typeof ngDevMode === "undefined" || ngDevMode) && ' + - // Main `setClassMetadataAsync` call 'i0.ɵsetClassMetadataAsync(TestCmp, ' + - // Dependency loading function (note: no local `LocalDep` here) - '() => [import("./cmp-a").then(m => m.CmpA)], ' + - // Callback that invokes `setClassMetadata` at the end + '() => [/* @ts-ignore */ import("./cmp-a").then(m => m.CmpA)], ' + 'CmpA => { i0.ɵsetClassMetadata(TestCmp', ); }); @@ -1494,14 +1502,13 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); expect(jsContents).toContain('ɵɵdefer(1, 0, TestCmp_Defer_1_DepsFn)'); - expect(jsContents).toContain( - // ngDevMode check is present + expect(cleanNewLines(jsContents)).toContain( '(() => { (typeof ngDevMode === "undefined" || ngDevMode) && ' + // Main `setClassMetadataAsync` call 'i0.ɵsetClassMetadataAsync(TestCmp, ' + // Dependency loading function (note: no local `LocalDep` here) - '() => [import("./cmp-a").then(m => m.default)], ' + // Callback that invokes `setClassMetadata` at the end + '() => [/* @ts-ignore */ import("./cmp-a").then(m => m.default)], ' + 'CmpA => { i0.ɵsetClassMetadata(TestCmp', ); }); diff --git a/packages/compiler-cli/test/ngtsc/local_compilation_spec.ts b/packages/compiler-cli/test/ngtsc/local_compilation_spec.ts index a766fe6b6387..5c0b0fb57ca6 100644 --- a/packages/compiler-cli/test/ngtsc/local_compilation_spec.ts +++ b/packages/compiler-cli/test/ngtsc/local_compilation_spec.ts @@ -16,6 +16,10 @@ import {NgtscTestEnvironment, TsConfigOptions} from './env'; const testFiles = loadStandardTestFiles(); +function cleanNewLines(contents: string) { + return contents.replace(/\n/g, ' ').replace(/\s+/g, ' '); +} + runInEachFileSystem(() => { describe('local compilation', () => { let env!: NgtscTestEnvironment; @@ -2213,9 +2217,9 @@ runInEachFileSystem(() => { // Expect that all deferrableImports in local compilation mode // are located in a single function (since we can't detect in // the local mode which components belong to which block). - expect(jsContents).toContain( - 'const AppCmp_DeferFn = () => [' + - 'import("./deferred-a").then(m => m.DeferredCmpA), ' + + expect(cleanNewLines(jsContents)).toContain( + 'const AppCmp_DeferFn = () => [/* @ts-ignore */ ' + + 'import("./deferred-a").then(m => m.DeferredCmpA), /* @ts-ignore */ ' + 'import("./deferred-b").then(m => m.DeferredCmpB)];', ); @@ -2228,9 +2232,9 @@ runInEachFileSystem(() => { expect(jsContents).toContain('ɵɵdefer(4, 3, AppCmp_DeferFn);'); // Expect `ɵsetClassMetadataAsync` to contain dynamic imports too. - expect(jsContents).toContain( - 'ɵsetClassMetadataAsync(AppCmp, () => [' + - 'import("./deferred-a").then(m => m.DeferredCmpA), ' + + expect(cleanNewLines(jsContents)).toContain( + 'ɵsetClassMetadataAsync(AppCmp, () => [/* @ts-ignore */ ' + + 'import("./deferred-a").then(m => m.DeferredCmpA), /* @ts-ignore */ ' + 'import("./deferred-b").then(m => m.DeferredCmpB)], ' + '(DeferredCmpA, DeferredCmpB) => {', ); @@ -2360,9 +2364,9 @@ runInEachFileSystem(() => { // are located in a single function (since we can't detect in // the local mode which components belong to which block). // Eager dependencies are **not* included here. - expect(jsContents).toContain( - 'const AppCmp_DeferFn = () => [' + - 'import("./deferred-a").then(m => m.DeferredCmpA), ' + + expect(cleanNewLines(jsContents)).toContain( + 'const AppCmp_DeferFn = () => [/* @ts-ignore */ ' + + 'import("./deferred-a").then(m => m.DeferredCmpA), /* @ts-ignore */ ' + 'import("./deferred-b").then(m => m.DeferredCmpB)];', ); @@ -2378,9 +2382,9 @@ runInEachFileSystem(() => { expect(jsContents).toContain('ɵɵdefer(4, 3, AppCmp_DeferFn);'); // Expect `ɵsetClassMetadataAsync` to contain dynamic imports too. - expect(jsContents).toContain( - 'ɵsetClassMetadataAsync(AppCmp, () => [' + - 'import("./deferred-a").then(m => m.DeferredCmpA), ' + + expect(cleanNewLines(jsContents)).toContain( + 'ɵsetClassMetadataAsync(AppCmp, () => [/* @ts-ignore */ ' + + 'import("./deferred-a").then(m => m.DeferredCmpA), /* @ts-ignore */ ' + 'import("./deferred-b").then(m => m.DeferredCmpB)], ' + '(DeferredCmpA, DeferredCmpB) => {', ); @@ -2448,12 +2452,12 @@ runInEachFileSystem(() => { // Expect that we generate 2 different defer functions // (one for each component). - expect(jsContents).toContain( - 'const AppCmpA_DeferFn = () => [' + + expect(cleanNewLines(jsContents)).toContain( + 'const AppCmpA_DeferFn = () => [/* @ts-ignore */ ' + 'import("./deferred-deps").then(m => m.DeferredCmpA)]', ); - expect(jsContents).toContain( - 'const AppCmpB_DeferFn = () => [' + + expect(cleanNewLines(jsContents)).toContain( + 'const AppCmpB_DeferFn = () => [/* @ts-ignore */ ' + 'import("./deferred-deps").then(m => m.DeferredCmpB)]', ); @@ -2465,12 +2469,12 @@ runInEachFileSystem(() => { expect(jsContents).toContain('ɵɵdefer(1, 0, AppCmpB_DeferFn)'); // Expect `ɵsetClassMetadataAsync` to contain dynamic imports too. - expect(jsContents).toContain( - 'ɵsetClassMetadataAsync(AppCmpA, () => [' + + expect(cleanNewLines(jsContents)).toContain( + 'ɵsetClassMetadataAsync(AppCmpA, () => [/* @ts-ignore */ ' + 'import("./deferred-deps").then(m => m.DeferredCmpA)]', ); - expect(jsContents).toContain( - 'ɵsetClassMetadataAsync(AppCmpB, () => [' + + expect(cleanNewLines(jsContents)).toContain( + 'ɵsetClassMetadataAsync(AppCmpB, () => [/* @ts-ignore */ ' + 'import("./deferred-deps").then(m => m.DeferredCmpB)]', ); }, diff --git a/packages/compiler-cli/test/ngtsc/selectorless_spec.ts b/packages/compiler-cli/test/ngtsc/selectorless_spec.ts index 34d47eb8cafe..74f4419a93ab 100644 --- a/packages/compiler-cli/test/ngtsc/selectorless_spec.ts +++ b/packages/compiler-cli/test/ngtsc/selectorless_spec.ts @@ -12,6 +12,10 @@ import {NgtscTestEnvironment} from './env'; const testFiles = loadStandardTestFiles(); +function cleanNewLines(contents: string) { + return contents.replace(/\n/g, ' ').replace(/\s+/g, ' '); +} + runInEachFileSystem(() => { describe('selectorless', () => { let env!: NgtscTestEnvironment; @@ -1112,10 +1116,10 @@ runInEachFileSystem(() => { expect(jsContents).not.toContain('import { DepComp'); expect(jsContents).not.toContain('import { DepDir'); expect(jsContents).not.toContain('import { DepPipe'); - expect(jsContents).toContain( - 'const Comp_Defer_1_DepsFn = () => [import("./dep-comp").then(m => m.DepComp), ' + - 'import("./dep-dir").then(m => m.DepDir), ' + - 'import("./dep-pipe").then(m => m.DepPipe)];', + expect(cleanNewLines(jsContents)).toContain( + 'const Comp_Defer_1_DepsFn = () => [/* @ts-ignore */ import("./dep-comp").then(m => m.DepComp), ' + + '/* @ts-ignore */ import("./dep-dir").then(m => m.DepDir), ' + + '/* @ts-ignore */ import("./dep-pipe").then(m => m.DepPipe)];', ); expect(jsContents).toContain('ɵɵdefer(1, 0, Comp_Defer_1_DepsFn);'); }); From 84fc709eeebc44eac7ff0b7022e4c41d494c6650 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 13 Mar 2026 14:17:25 +0100 Subject: [PATCH 09/10] refactor(compiler): rename isolated tests to codegen Renames the test target so it's a bit clearer what it's targeting. --- .../test/compliance/{isolated => codegen}/BUILD.bazel | 4 ++-- .../codegen_compile_spec.ts} | 0 packages/compiler-cli/test/compliance/test_cases/BUILD.bazel | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) rename packages/compiler-cli/test/compliance/{isolated => codegen}/BUILD.bazel (89%) rename packages/compiler-cli/test/compliance/{isolated/isolated_compile_spec.ts => codegen/codegen_compile_spec.ts} (100%) diff --git a/packages/compiler-cli/test/compliance/isolated/BUILD.bazel b/packages/compiler-cli/test/compliance/codegen/BUILD.bazel similarity index 89% rename from packages/compiler-cli/test/compliance/isolated/BUILD.bazel rename to packages/compiler-cli/test/compliance/codegen/BUILD.bazel index d70dc0aac8f9..2e8dd067cf8f 100644 --- a/packages/compiler-cli/test/compliance/isolated/BUILD.bazel +++ b/packages/compiler-cli/test/compliance/codegen/BUILD.bazel @@ -3,7 +3,7 @@ load("//tools:defaults.bzl", "jasmine_test", "ts_project") ts_project( name = "test_lib", testonly = True, - srcs = ["isolated_compile_spec.ts"], + srcs = ["codegen_compile_spec.ts"], deps = [ "//:node_modules/typescript", "//packages/compiler-cli", @@ -14,7 +14,7 @@ ts_project( ) jasmine_test( - name = "isolated", + name = "codegen", data = [ ":test_lib", "//packages/compiler-cli/test/compliance/test_cases", diff --git a/packages/compiler-cli/test/compliance/isolated/isolated_compile_spec.ts b/packages/compiler-cli/test/compliance/codegen/codegen_compile_spec.ts similarity index 100% rename from packages/compiler-cli/test/compliance/isolated/isolated_compile_spec.ts rename to packages/compiler-cli/test/compliance/codegen/codegen_compile_spec.ts diff --git a/packages/compiler-cli/test/compliance/test_cases/BUILD.bazel b/packages/compiler-cli/test/compliance/test_cases/BUILD.bazel index 116421b05fd4..fedf8ebdeacd 100644 --- a/packages/compiler-cli/test/compliance/test_cases/BUILD.bazel +++ b/packages/compiler-cli/test/compliance/test_cases/BUILD.bazel @@ -10,5 +10,4 @@ copy_to_bin( [partial_compliance_golden(filePath = path) for path in glob( include = ["**/TEST_CASES.json"], - exclude = ["**/isolated/TEST_CASES.json"], )] From ceb6334fcbcf4568dc51e9c3d7d383b3bfc7d9a1 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 13 Mar 2026 19:31:58 +0100 Subject: [PATCH 10/10] refactor(compiler): update tests after codegen changes Updates the compliance tests to account for the recent changes. --- .../test_cases/model_inputs/GOLDEN_PARTIAL.js | 15 +++++--- .../animations/GOLDEN_PARTIAL.js | 6 ++-- .../GOLDEN_PARTIAL.js | 15 +++++--- .../control_bindings/GOLDEN_PARTIAL.js | 6 ++-- .../for_impure_track_reuse_template.js | 1 + ...r_track_by_temporary_variables_template.js | 10 ++---- .../for_track_literals_template.js | 1 + .../nested_for_tracking_function_template.js | 3 ++ .../GOLDEN_PARTIAL.js | 35 ++++++++++++------ .../defer_default_deps_template.js | 11 ++++-- .../defer_deps_template.js | 11 ++++-- ...ed_with_duplicate_external_dep_template.js | 12 +++++-- .../deferred_with_external_deps_template.js | 10 ++++-- .../r3_view_compiler_di/di/GOLDEN_PARTIAL.js | 5 +-- .../di/useclass_with_deps.ts | 1 + .../blocks/conditional_template.js | 3 +- .../blocks/defer_template.js | 3 +- .../blocks/for_template.js | 3 +- .../blocks/switch_template.js | 3 +- .../element_attributes/invalid_i18n_meta.js | 6 ++-- .../meaning_description_template.js | 6 ++-- .../icu_logic/attribute_interpolation.js | 9 +++-- .../icu_logic/escape_quotes.js | 5 +-- .../icu_logic/root_icu_with_elements.js | 4 +-- .../icu_logic/shared_placeholder.js | 12 ++++--- .../legacy_disabled.js | 1 + .../legacy_enabled.js | 26 +++++++++----- .../namespaces/foreign_object.js | 3 +- .../namespaces/namespaced_div.js | 3 +- .../nested_nodes/backtick_quotes.js | 3 +- .../nested_nodes/escape_quotes.js | 3 +- .../nested_nodes/named_interpolations.js | 3 +- .../preserve_inner_content.js | 3 +- .../let_in_child_view_inside_i18n_template.js | 3 +- .../let_in_i18n_and_child_view_template.js | 3 +- .../let_in_i18n_template.js | 3 +- .../let_preceded_by_i18n_template.js | 3 +- .../GOLDEN_PARTIAL.js | 6 ++-- .../signal_inputs/GOLDEN_PARTIAL.js | 15 +++++--- .../signal_queries/GOLDEN_PARTIAL.js | 36 ++++++++++++------- .../compliance/test_helpers/i18n_helpers.ts | 3 +- .../test/ngtsc/debug_transform_spec.ts | 2 +- .../compiler-cli/test/ngtsc/defer_spec.ts | 6 ++-- .../test/ngtsc/local_compilation_spec.ts | 2 +- .../test/ngtsc/selectorless_spec.ts | 2 +- 45 files changed, 220 insertions(+), 105 deletions(-) diff --git a/packages/compiler-cli/test/compliance/test_cases/model_inputs/GOLDEN_PARTIAL.js b/packages/compiler-cli/test/compliance/test_cases/model_inputs/GOLDEN_PARTIAL.js index fdd1c19068ef..6ffbe37cfd71 100644 --- a/packages/compiler-cli/test/compliance/test_cases/model_inputs/GOLDEN_PARTIAL.js +++ b/packages/compiler-cli/test/compliance/test_cases/model_inputs/GOLDEN_PARTIAL.js @@ -4,8 +4,10 @@ import { Directive, model } from '@angular/core'; import * as i0 from "@angular/core"; export class TestDir { - counter = model(0, ...(ngDevMode ? [{ debugName: "counter" }] : /* istanbul ignore next */ [])); - name = model.required(...(ngDevMode ? [{ debugName: "name" }] : /* istanbul ignore next */ [])); + counter = model(0, /* @ts-ignore */ + ...(ngDevMode ? [{ debugName: "counter" }] : /* istanbul ignore next */ [])); + name = model.required(/* @ts-ignore */ + ...(ngDevMode ? [{ debugName: "name" }] : /* istanbul ignore next */ [])); static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "0.0.0-PLACEHOLDER", ngImport: i0, type: TestDir, deps: [], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "0.0.0-PLACEHOLDER", type: TestDir, isStandalone: true, inputs: { counter: { classPropertyName: "counter", publicName: "counter", isSignal: true, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { counter: "counterChange", name: "nameChange" }, ngImport: i0 }); } @@ -31,8 +33,10 @@ export declare class TestDir { import { Component, model } from '@angular/core'; import * as i0 from "@angular/core"; export class TestComp { - counter = model(0, ...(ngDevMode ? [{ debugName: "counter" }] : /* istanbul ignore next */ [])); - name = model.required(...(ngDevMode ? [{ debugName: "name" }] : /* istanbul ignore next */ [])); + counter = model(0, /* @ts-ignore */ + ...(ngDevMode ? [{ debugName: "counter" }] : /* istanbul ignore next */ [])); + name = model.required(/* @ts-ignore */ + ...(ngDevMode ? [{ debugName: "name" }] : /* istanbul ignore next */ [])); static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "0.0.0-PLACEHOLDER", ngImport: i0, type: TestComp, deps: [], target: i0.ɵɵFactoryTarget.Component }); static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "0.0.0-PLACEHOLDER", type: TestComp, isStandalone: true, selector: "ng-component", inputs: { counter: { classPropertyName: "counter", publicName: "counter", isSignal: true, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { counter: "counterChange", name: "nameChange" }, ngImport: i0, template: 'Works', isInline: true }); } @@ -60,7 +64,8 @@ export declare class TestComp { import { Directive, EventEmitter, Input, model, Output } from '@angular/core'; import * as i0 from "@angular/core"; export class TestDir { - counter = model(0, ...(ngDevMode ? [{ debugName: "counter" }] : /* istanbul ignore next */ [])); + counter = model(0, /* @ts-ignore */ + ...(ngDevMode ? [{ debugName: "counter" }] : /* istanbul ignore next */ [])); modelWithAlias = model(false, { ...(ngDevMode ? { debugName: "modelWithAlias" } : /* istanbul ignore next */ {}), alias: 'alias' }); decoratorInput = true; decoratorInputWithAlias = true; diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler/animations/GOLDEN_PARTIAL.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler/animations/GOLDEN_PARTIAL.js index cf4ff6c31f5e..fd8cf5b8ea3e 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler/animations/GOLDEN_PARTIAL.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler/animations/GOLDEN_PARTIAL.js @@ -187,7 +187,8 @@ export declare class MyComponent { import { Component, signal } from '@angular/core'; import * as i0 from "@angular/core"; export class MyComponent { - enterClass = signal('slide', ...(ngDevMode ? [{ debugName: "enterClass" }] : /* istanbul ignore next */ [])); + enterClass = signal('slide', /* @ts-ignore */ + ...(ngDevMode ? [{ debugName: "enterClass" }] : /* istanbul ignore next */ [])); static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "0.0.0-PLACEHOLDER", ngImport: i0, type: MyComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "0.0.0-PLACEHOLDER", type: MyComponent, isStandalone: true, selector: "my-component", ngImport: i0, template: `
@@ -296,7 +297,8 @@ export declare class MyComponent { import { Component, signal } from '@angular/core'; import * as i0 from "@angular/core"; export class MyComponent { - leaveClass = signal('fade', ...(ngDevMode ? [{ debugName: "leaveClass" }] : /* istanbul ignore next */ [])); + leaveClass = signal('fade', /* @ts-ignore */ + ...(ngDevMode ? [{ debugName: "leaveClass" }] : /* istanbul ignore next */ [])); static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "0.0.0-PLACEHOLDER", ngImport: i0, type: MyComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "0.0.0-PLACEHOLDER", type: MyComponent, isStandalone: true, selector: "my-component", ngImport: i0, template: `
diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_arrow_functions/GOLDEN_PARTIAL.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_arrow_functions/GOLDEN_PARTIAL.js index 1a2708a79137..af3ca12019f4 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_arrow_functions/GOLDEN_PARTIAL.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_arrow_functions/GOLDEN_PARTIAL.js @@ -4,8 +4,10 @@ import { Component, signal } from '@angular/core'; import * as i0 from "@angular/core"; export class TestComp { - sigA = signal(1, ...(ngDevMode ? [{ debugName: "sigA" }] : /* istanbul ignore next */ [])); - sigB = signal(2, ...(ngDevMode ? [{ debugName: "sigB" }] : /* istanbul ignore next */ [])); + sigA = signal(1, /* @ts-ignore */ + ...(ngDevMode ? [{ debugName: "sigA" }] : /* istanbul ignore next */ [])); + sigB = signal(2, /* @ts-ignore */ + ...(ngDevMode ? [{ debugName: "sigB" }] : /* istanbul ignore next */ [])); static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "0.0.0-PLACEHOLDER", ngImport: i0, type: TestComp, deps: [], target: i0.ɵɵFactoryTarget.Component }); static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "0.0.0-PLACEHOLDER", type: TestComp, isStandalone: true, selector: "ng-component", ngImport: i0, template: ` @@ -144,7 +146,8 @@ export declare class TestComp { import { Component, signal } from '@angular/core'; import * as i0 from "@angular/core"; export class TestComp { - someSignal = signal('', ...(ngDevMode ? [{ debugName: "someSignal" }] : /* istanbul ignore next */ [])); + someSignal = signal('', /* @ts-ignore */ + ...(ngDevMode ? [{ debugName: "someSignal" }] : /* istanbul ignore next */ [])); componentProp = 0; static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "0.0.0-PLACEHOLDER", ngImport: i0, type: TestComp, deps: [], target: i0.ɵɵFactoryTarget.Component }); static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "0.0.0-PLACEHOLDER", type: TestComp, isStandalone: true, selector: "ng-component", ngImport: i0, template: ` @@ -272,7 +275,8 @@ export declare class TestDir { import { Directive, signal } from '@angular/core'; import * as i0 from "@angular/core"; export class TestDir { - someSignal = signal(0, ...(ngDevMode ? [{ debugName: "someSignal" }] : /* istanbul ignore next */ [])); + someSignal = signal(0, /* @ts-ignore */ + ...(ngDevMode ? [{ debugName: "someSignal" }] : /* istanbul ignore next */ [])); componentProp = 1; static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "0.0.0-PLACEHOLDER", ngImport: i0, type: TestDir, deps: [], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "0.0.0-PLACEHOLDER", type: TestDir, isStandalone: true, host: { listeners: { "click": "someSignal.update(prev => prev + 1)", "mousedown": "someSignal.update(() => componentProp + 1)" } }, ngImport: i0 }); @@ -611,7 +615,8 @@ import { Component, signal } from '@angular/core'; import * as i0 from "@angular/core"; export class TestComp { componentProp = 0; - result = signal('', ...(ngDevMode ? [{ debugName: "result" }] : /* istanbul ignore next */ [])); + result = signal('', /* @ts-ignore */ + ...(ngDevMode ? [{ debugName: "result" }] : /* istanbul ignore next */ [])); static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "0.0.0-PLACEHOLDER", ngImport: i0, type: TestComp, deps: [], target: i0.ɵɵFactoryTarget.Component }); static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "0.0.0-PLACEHOLDER", type: TestComp, isStandalone: true, selector: "ng-component", ngImport: i0, template: ` @let topLevelLet = 1; diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_bindings/control_bindings/GOLDEN_PARTIAL.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_bindings/control_bindings/GOLDEN_PARTIAL.js index 11cb5eee6a57..b91a161a08d1 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_bindings/control_bindings/GOLDEN_PARTIAL.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_bindings/control_bindings/GOLDEN_PARTIAL.js @@ -4,7 +4,8 @@ import { Component, Directive, input } from '@angular/core'; import * as i0 from "@angular/core"; export class FormField { - formField = input(...(ngDevMode ? [undefined, { debugName: "formField" }] : /* istanbul ignore next */ [])); + formField = input(/* @ts-ignore */ + ...(ngDevMode ? [undefined, { debugName: "formField" }] : /* istanbul ignore next */ [])); static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "0.0.0-PLACEHOLDER", ngImport: i0, type: FormField, deps: [], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "0.0.0-PLACEHOLDER", type: FormField, isStandalone: true, selector: "[formField]", inputs: { formField: { classPropertyName: "formField", publicName: "formField", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 }); } @@ -54,7 +55,8 @@ export declare class MyComponent { import { Component, Directive, input } from '@angular/core'; import * as i0 from "@angular/core"; export class FormField { - formField = input(...(ngDevMode ? [undefined, { debugName: "formField" }] : /* istanbul ignore next */ [])); + formField = input(/* @ts-ignore */ + ...(ngDevMode ? [undefined, { debugName: "formField" }] : /* istanbul ignore next */ [])); static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "0.0.0-PLACEHOLDER", ngImport: i0, type: FormField, deps: [], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "0.0.0-PLACEHOLDER", type: FormField, isStandalone: true, selector: "[formField]", inputs: { formField: { classPropertyName: "formField", publicName: "formField", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 }); } diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_control_flow/for_impure_track_reuse_template.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_control_flow/for_impure_track_reuse_template.js index 7107664c2d91..fc72f56cfc93 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_control_flow/for_impure_track_reuse_template.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_control_flow/for_impure_track_reuse_template.js @@ -1,4 +1,5 @@ function $_forTrack0$($index, $item) { + /* @ts-ignore */ return this.trackFn($item, this.message); } … diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_control_flow/for_track_by_temporary_variables_template.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_control_flow/for_track_by_temporary_variables_template.js index 4224c7b59ad2..96bbc0fc2469 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_control_flow/for_track_by_temporary_variables_template.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_control_flow/for_track_by_temporary_variables_template.js @@ -1,14 +1,10 @@ function _forTrack0($index, $item) { - return ($item == null - ? null - : $item.name == null - ? null - : $item.name[0] == null - ? null - : $item.name[0].toUpperCase()) ?? this.foo; + /* @ts-ignore */ + return ($item == null ? null : $item.name == null ? null : $item.name[0] == null ? null : $item.name[0].toUpperCase()) ?? this.foo; } function _forTrack1($index, $item) { + /* @ts-ignore */ return $item.name ?? $index ?? this.foo; } diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_control_flow/for_track_literals_template.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_control_flow/for_track_literals_template.js index 43e0ccd8f857..3d1021ee1375 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_control_flow/for_track_literals_template.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_control_flow/for_track_literals_template.js @@ -1,4 +1,5 @@ function $_forTrack0$($index, $item) { + /* @ts-ignore */ return this.trackFn({ foo: $item, bar: $item diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_control_flow/nested_for_tracking_function_template.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_control_flow/nested_for_tracking_function_template.js index 81eac05a0b24..e143a155bb87 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_control_flow/nested_for_tracking_function_template.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_control_flow/nested_for_tracking_function_template.js @@ -1,12 +1,15 @@ function _forTrack0($index, $item) { + /* @ts-ignore */ return this.trackByGrandparent($item, $index); } function _forTrack1($index, $item) { + /* @ts-ignore */ return this.trackByParent($item, $index); } function _forTrack2($index, $item) { + /* @ts-ignore */ return this.trackByChild($item, $index); } diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_deferred/GOLDEN_PARTIAL.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_deferred/GOLDEN_PARTIAL.js index ea4e4912b3b3..c32e363584e9 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_deferred/GOLDEN_PARTIAL.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_deferred/GOLDEN_PARTIAL.js @@ -395,9 +395,11 @@ export class MyApp { }
- `, isInline: true, dependencies: [{ kind: "directive", type: EagerDep, selector: "eager-dep" }, { kind: "directive", type: LoadingDep, selector: "loading-dep" }], deferBlockDependencies: [() => [import("./deferred_with_external_deps_lazy").then(m => m.LazyDep)]] }); + `, isInline: true, dependencies: [{ kind: "directive", type: EagerDep, selector: "eager-dep" }, { kind: "directive", type: LoadingDep, selector: "loading-dep" }], deferBlockDependencies: [() => [/* @ts-ignore */ + import("./deferred_with_external_deps_lazy").then(m => m.LazyDep)]] }); } -i0.ɵɵngDeclareClassMetadataAsync({ minVersion: "18.0.0", version: "0.0.0-PLACEHOLDER", ngImport: i0, type: MyApp, resolveDeferredDeps: () => [import("./deferred_with_external_deps_lazy").then(m => m.LazyDep)], resolveMetadata: LazyDep => ({ decorators: [{ +i0.ɵɵngDeclareClassMetadataAsync({ minVersion: "18.0.0", version: "0.0.0-PLACEHOLDER", ngImport: i0, type: MyApp, resolveDeferredDeps: () => [/* @ts-ignore */ + import("./deferred_with_external_deps_lazy").then(m => m.LazyDep)], resolveMetadata: LazyDep => ({ decorators: [{ type: Component, args: [{ template: ` @@ -927,9 +929,11 @@ export class TestCmp { } -`, isInline: true, deferBlockDependencies: [() => [import("./defer_deps_ext").then(m => m.CmpA), LocalDep]] }); +`, isInline: true, deferBlockDependencies: [() => [/* @ts-ignore */ + import("./defer_deps_ext").then(m => m.CmpA), LocalDep]] }); } -i0.ɵɵngDeclareClassMetadataAsync({ minVersion: "18.0.0", version: "0.0.0-PLACEHOLDER", ngImport: i0, type: TestCmp, resolveDeferredDeps: () => [import("./defer_deps_ext").then(m => m.CmpA)], resolveMetadata: CmpA => ({ decorators: [{ +i0.ɵɵngDeclareClassMetadataAsync({ minVersion: "18.0.0", version: "0.0.0-PLACEHOLDER", ngImport: i0, type: TestCmp, resolveDeferredDeps: () => [/* @ts-ignore */ + import("./defer_deps_ext").then(m => m.CmpA)], resolveMetadata: CmpA => ({ decorators: [{ type: Component, args: [{ selector: 'test-cmp', @@ -1002,9 +1006,11 @@ export class TestCmp { } -`, isInline: true, deferBlockDependencies: [() => [import("./defer_default_deps_ext").then(m => m.default), LocalDep]] }); +`, isInline: true, deferBlockDependencies: [() => [/* @ts-ignore */ + import("./defer_default_deps_ext").then(m => m.default), LocalDep]] }); } -i0.ɵɵngDeclareClassMetadataAsync({ minVersion: "18.0.0", version: "0.0.0-PLACEHOLDER", ngImport: i0, type: TestCmp, resolveDeferredDeps: () => [import("./defer_default_deps_ext").then(m => m.default)], resolveMetadata: CmpA => ({ decorators: [{ +i0.ɵɵngDeclareClassMetadataAsync({ minVersion: "18.0.0", version: "0.0.0-PLACEHOLDER", ngImport: i0, type: TestCmp, resolveDeferredDeps: () => [/* @ts-ignore */ + import("./defer_default_deps_ext").then(m => m.default)], resolveMetadata: CmpA => ({ decorators: [{ type: Component, args: [{ selector: 'test-cmp', @@ -1162,9 +1168,14 @@ export class MyApp { @defer { } - `, isInline: true, deferBlockDependencies: [() => [import("./deferred_with_duplicate_external_dep_lazy").then(m => m.DuplicateLazyDep)], () => [import("./deferred_with_duplicate_external_dep_lazy").then(m => m.DuplicateLazyDep)], () => [import("./deferred_with_duplicate_external_dep_other").then(m => m.OtherLazyDep)]] }); -} -i0.ɵɵngDeclareClassMetadataAsync({ minVersion: "18.0.0", version: "0.0.0-PLACEHOLDER", ngImport: i0, type: MyApp, resolveDeferredDeps: () => [import("./deferred_with_duplicate_external_dep_lazy").then(m => m.DuplicateLazyDep), import("./deferred_with_duplicate_external_dep_other").then(m => m.OtherLazyDep)], resolveMetadata: (DuplicateLazyDep, OtherLazyDep) => ({ decorators: [{ + `, isInline: true, deferBlockDependencies: [() => [/* @ts-ignore */ + import("./deferred_with_duplicate_external_dep_lazy").then(m => m.DuplicateLazyDep)], () => [/* @ts-ignore */ + import("./deferred_with_duplicate_external_dep_lazy").then(m => m.DuplicateLazyDep)], () => [/* @ts-ignore */ + import("./deferred_with_duplicate_external_dep_other").then(m => m.OtherLazyDep)]] }); +} +i0.ɵɵngDeclareClassMetadataAsync({ minVersion: "18.0.0", version: "0.0.0-PLACEHOLDER", ngImport: i0, type: MyApp, resolveDeferredDeps: () => [/* @ts-ignore */ + import("./deferred_with_duplicate_external_dep_lazy").then(m => m.DuplicateLazyDep), /* @ts-ignore */ + import("./deferred_with_duplicate_external_dep_other").then(m => m.OtherLazyDep)], resolveMetadata: (DuplicateLazyDep, OtherLazyDep) => ({ decorators: [{ type: Component, args: [{ template: ` @@ -1241,9 +1252,11 @@ export class TestCmp { @defer { } - `, isInline: true, deferBlockDependencies: [() => [import("./deferred_import_alias_index").then(m => m.MyCounterCmp)]] }); + `, isInline: true, deferBlockDependencies: [() => [/* @ts-ignore */ + import("./deferred_import_alias_index").then(m => m.MyCounterCmp)]] }); } -i0.ɵɵngDeclareClassMetadataAsync({ minVersion: "18.0.0", version: "0.0.0-PLACEHOLDER", ngImport: i0, type: TestCmp, resolveDeferredDeps: () => [import("./deferred_import_alias_index").then(m => m.MyCounterCmp)], resolveMetadata: MyCounterCmp => ({ decorators: [{ +i0.ɵɵngDeclareClassMetadataAsync({ minVersion: "18.0.0", version: "0.0.0-PLACEHOLDER", ngImport: i0, type: TestCmp, resolveDeferredDeps: () => [/* @ts-ignore */ + import("./deferred_import_alias_index").then(m => m.MyCounterCmp)], resolveMetadata: MyCounterCmp => ({ decorators: [{ type: Component, args: [{ selector: 'test-cmp', diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_deferred/defer_default_deps_template.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_deferred/defer_default_deps_template.js index a3be09b2e069..cd4a0bb2254d 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_deferred/defer_default_deps_template.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_deferred/defer_default_deps_template.js @@ -1,4 +1,8 @@ -const $TestCmp_Defer_1_DepsFn$ = () => [import("./defer_default_deps_ext").then(m => m.default), LocalDep]; +const $TestCmp_Defer_1_DepsFn$ = () => [ + /* @ts-ignore */ + import("./defer_default_deps_ext").then(m => m.default), + LocalDep +]; function TestCmp_Defer_0_Template(rf, ctx) { if (rf & 1) { @@ -23,7 +27,10 @@ function TestCmp_Template(rf, ctx) { … (() => { - (typeof ngDevMode === "undefined" || ngDevMode) && $r3$.ɵsetClassMetadataAsync(TestCmp, () => [import("./defer_default_deps_ext").then(m => m.default)], CmpA => { + (typeof ngDevMode === "undefined" || ngDevMode) && $r3$.ɵsetClassMetadataAsync(TestCmp, () => [ + /* @ts-ignore */ + import("./defer_default_deps_ext").then(m => m.default) + ], CmpA => { $r3$.ɵsetClassMetadata(TestCmp, [{ type: Component, args: [{ diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_deferred/defer_deps_template.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_deferred/defer_deps_template.js index 281335b31ea4..35166c0a4c69 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_deferred/defer_deps_template.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_deferred/defer_deps_template.js @@ -1,4 +1,8 @@ -const $TestCmp_Defer_1_DepsFn$ = () => [import("./defer_deps_ext").then(m => m.CmpA), LocalDep]; +const $TestCmp_Defer_1_DepsFn$ = () => [ + /* @ts-ignore */ + import("./defer_deps_ext").then(m => m.CmpA), + LocalDep +]; function TestCmp_Defer_0_Template(rf, ctx) { if (rf & 1) { @@ -21,7 +25,10 @@ function TestCmp_Template(rf, ctx) { if (rf & 1) { … (() => { - (typeof ngDevMode === "undefined" || ngDevMode) && $r3$.ɵsetClassMetadataAsync(TestCmp, () => [import("./defer_deps_ext").then(m => m.CmpA)], CmpA => { + (typeof ngDevMode === "undefined" || ngDevMode) && $r3$.ɵsetClassMetadataAsync(TestCmp, () => [ + /* @ts-ignore */ + import("./defer_deps_ext").then(m => m.CmpA) + ], CmpA => { $r3$.ɵsetClassMetadata(TestCmp, [{ type: Component, args: [{ diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_deferred/deferred_with_duplicate_external_dep_template.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_deferred/deferred_with_duplicate_external_dep_template.js index 10e1bd05d957..ffdfd4b04d05 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_deferred/deferred_with_duplicate_external_dep_template.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_deferred/deferred_with_duplicate_external_dep_template.js @@ -1,7 +1,13 @@ -const MyApp_Defer_1_DepsFn = () => [import("./deferred_with_duplicate_external_dep_lazy").then(m => m.DuplicateLazyDep)]; +const MyApp_Defer_1_DepsFn = () => [ + /* @ts-ignore */ + import("./deferred_with_duplicate_external_dep_lazy").then(m => m.DuplicateLazyDep) +]; // NOTE: in linked tests there is one more loader here, because linked compilation doesn't have the ability to de-dupe identical functions. … -const MyApp_Defer_7_DepsFn = () => [import("./deferred_with_duplicate_external_dep_other").then(m => m.OtherLazyDep)]; +const MyApp_Defer_7_DepsFn = () => [ + /* @ts-ignore */ + import("./deferred_with_duplicate_external_dep_other").then(m => m.OtherLazyDep) +]; … @@ -28,7 +34,9 @@ $r3$.ɵɵdefineComponent({ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && $r3$.ɵsetClassMetadataAsync(MyApp, () => [ + /* @ts-ignore */ import("./deferred_with_duplicate_external_dep_lazy").then(m => m.DuplicateLazyDep), + /* @ts-ignore */ import("./deferred_with_duplicate_external_dep_other").then(m => m.OtherLazyDep) ], (DuplicateLazyDep, OtherLazyDep) => { $r3$.ɵsetClassMetadata(MyApp, [{ diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_deferred/deferred_with_external_deps_template.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_deferred/deferred_with_external_deps_template.js index 9da88cfba9fc..7d3cfe02a9d4 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_deferred/deferred_with_external_deps_template.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_deferred/deferred_with_external_deps_template.js @@ -2,7 +2,10 @@ import {EagerDep} from './deferred_with_external_deps_eager'; import {LoadingDep} from './deferred_with_external_deps_loading'; import * as $r3$ from "@angular/core"; -const $MyApp_Defer_4_DepsFn$ = () => [import("./deferred_with_external_deps_lazy").then(m => m.LazyDep)]; +const $MyApp_Defer_4_DepsFn$ = () => [ + /* @ts-ignore */ + import("./deferred_with_external_deps_lazy").then(m => m.LazyDep) +]; function MyApp_Defer_2_Template(rf, ctx) { if (rf & 1) { @@ -38,7 +41,10 @@ export class MyApp { … (() => { - (typeof ngDevMode === "undefined" || ngDevMode) && $r3$.ɵsetClassMetadataAsync(MyApp, () => [import("./deferred_with_external_deps_lazy").then(m => m.LazyDep)], LazyDep => { + (typeof ngDevMode === "undefined" || ngDevMode) && $r3$.ɵsetClassMetadataAsync(MyApp, () => [ + /* @ts-ignore */ + import("./deferred_with_external_deps_lazy").then(m => m.LazyDep) + ], LazyDep => { $r3$.ɵsetClassMetadata(MyApp, [{ type: Component, args: [{ diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/GOLDEN_PARTIAL.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/GOLDEN_PARTIAL.js index 21664445f476..1f80e591e47f 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/GOLDEN_PARTIAL.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/GOLDEN_PARTIAL.js @@ -232,12 +232,13 @@ import * as i0 from "@angular/core"; class SomeDep { } class MyAlternateService { - static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "0.0.0-PLACEHOLDER", ngImport: i0, type: MyAlternateService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); + constructor(dep) { } + static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "0.0.0-PLACEHOLDER", ngImport: i0, type: MyAlternateService, deps: [{ token: SomeDep }], target: i0.ɵɵFactoryTarget.Injectable }); static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "0.0.0-PLACEHOLDER", ngImport: i0, type: MyAlternateService }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "0.0.0-PLACEHOLDER", ngImport: i0, type: MyAlternateService, decorators: [{ type: Injectable - }] }); + }], ctorParameters: () => [{ type: SomeDep }] }); export class MyService { static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "0.0.0-PLACEHOLDER", ngImport: i0, type: MyService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "0.0.0-PLACEHOLDER", ngImport: i0, type: MyService, providedIn: 'root', useClass: MyAlternateService, deps: [{ token: SomeDep }] }); diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/useclass_with_deps.ts b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/useclass_with_deps.ts index 687bdf02470c..db28edb50082 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/useclass_with_deps.ts +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/useclass_with_deps.ts @@ -4,6 +4,7 @@ class SomeDep {} @Injectable() class MyAlternateService { + constructor(dep: SomeDep) {} } @Injectable({providedIn: 'root', useClass: MyAlternateService, deps: [SomeDep]}) diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/blocks/conditional_template.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/blocks/conditional_template.js index 09c1e9106968..19a792b4a08c 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/blocks/conditional_template.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/blocks/conditional_template.js @@ -41,7 +41,7 @@ export class MyApp { /** * @suppress {msgDescriptions} */ - const $MSG_ID_WITH_SUFFIX$ = goog.getMsg(" Content: {$startBlockIf} before{$startTagSpan}zero{$closeTagSpan}after {$closeBlockIf}{$startBlockElseIf} before{$startTagDiv}one{$closeTagDiv}after {$closeBlockElseIf}{$startBlockElse} before{$startTagButton}otherwise{$closeTagButton}after {$closeBlockElse}! {$startBlockIf_1} before{$startTagSpan}seven{$closeTagSpan}after {$closeBlockIf}", { + const $MSG_ID_WITH_SUFFIX$ = /* @ts-ignore */ goog.getMsg(" Content: {$startBlockIf} before{$startTagSpan}zero{$closeTagSpan}after {$closeBlockIf}{$startBlockElseIf} before{$startTagDiv}one{$closeTagDiv}after {$closeBlockElseIf}{$startBlockElse} before{$startTagButton}otherwise{$closeTagButton}after {$closeBlockElse}! {$startBlockIf_1} before{$startTagSpan}seven{$closeTagSpan}after {$closeBlockIf}", { "closeBlockElse": "\uFFFD/*4:3\uFFFD", "closeBlockElseIf": "\uFFFD/*3:2\uFFFD", "closeBlockIf": "[\uFFFD/*2:1\uFFFD|\uFFFD/*5:4\uFFFD]", @@ -74,6 +74,7 @@ export class MyApp { }); i18n_0 = $MSG_ID_WITH_SUFFIX$; } else { + /* @ts-ignore */ i18n_0 = $localize` Content: ${"\uFFFD*2:1\uFFFD"}:START_BLOCK_IF: before${"[\uFFFD#1:1\uFFFD|\uFFFD#1:4\uFFFD]"}:START_TAG_SPAN:zero${"[\uFFFD/#1:1\uFFFD|\uFFFD/#1:4\uFFFD]"}:CLOSE_TAG_SPAN:after ${"[\uFFFD/*2:1\uFFFD|\uFFFD/*5:4\uFFFD]"}:CLOSE_BLOCK_IF:${"\uFFFD*3:2\uFFFD"}:START_BLOCK_ELSE_IF: before${"\uFFFD#1:2\uFFFD"}:START_TAG_DIV:one${"\uFFFD/#1:2\uFFFD"}:CLOSE_TAG_DIV:after ${"\uFFFD/*3:2\uFFFD"}:CLOSE_BLOCK_ELSE_IF:${"\uFFFD*4:3\uFFFD"}:START_BLOCK_ELSE: before${"\uFFFD#1:3\uFFFD"}:START_TAG_BUTTON:otherwise${"\uFFFD/#1:3\uFFFD"}:CLOSE_TAG_BUTTON:after ${"\uFFFD/*4:3\uFFFD"}:CLOSE_BLOCK_ELSE:! ${"\uFFFD*5:4\uFFFD"}:START_BLOCK_IF_1: before${"[\uFFFD#1:1\uFFFD|\uFFFD#1:4\uFFFD]"}:START_TAG_SPAN:seven${"[\uFFFD/#1:1\uFFFD|\uFFFD/#1:4\uFFFD]"}:CLOSE_TAG_SPAN:after ${"[\uFFFD/*2:1\uFFFD|\uFFFD/*5:4\uFFFD]"}:CLOSE_BLOCK_IF:`; } i18n_0 = $r3$.ɵɵi18nPostprocess(i18n_0); diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/blocks/defer_template.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/blocks/defer_template.js index 877c7882427c..a047e2c2be2f 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/blocks/defer_template.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/blocks/defer_template.js @@ -42,7 +42,7 @@ export class MyApp { /** * @suppress {msgDescriptions} */ - const $MSG_ID_WITH_SUFFIX$ = goog.getMsg(" Content: {$startBlockDefer} before{$startTagSpan}middle{$closeTagSpan}after {$closeBlockDefer}{$startBlockPlaceholder} before{$startTagDiv}placeholder{$closeTagDiv}after {$closeBlockPlaceholder}{$startBlockLoading} before{$startTagButton}loading{$closeTagButton}after {$closeBlockLoading}{$startBlockError} before{$startHeadingLevel1}error{$closeHeadingLevel1}after {$closeBlockError}", { + const $MSG_ID_WITH_SUFFIX$ = /* @ts-ignore */ goog.getMsg(" Content: {$startBlockDefer} before{$startTagSpan}middle{$closeTagSpan}after {$closeBlockDefer}{$startBlockPlaceholder} before{$startTagDiv}placeholder{$closeTagDiv}after {$closeBlockPlaceholder}{$startBlockLoading} before{$startTagButton}loading{$closeTagButton}after {$closeBlockLoading}{$startBlockError} before{$startHeadingLevel1}error{$closeHeadingLevel1}after {$closeBlockError}", { "closeBlockDefer": "\uFFFD/*2:1\uFFFD", "closeBlockError": "\uFFFD/*5:4\uFFFD", "closeBlockLoading": "\uFFFD/*3:2\uFFFD", @@ -81,6 +81,7 @@ export class MyApp { }); i18n_0 = $MSG_ID_WITH_SUFFIX$; } else { + /* @ts-ignore */ i18n_0 = $localize ` Content: ${"\uFFFD*2:1\uFFFD"}:START_BLOCK_DEFER: before${"\uFFFD#1:1\uFFFD"}:START_TAG_SPAN:middle${"\uFFFD/#1:1\uFFFD"}:CLOSE_TAG_SPAN:after ${"\uFFFD/*2:1\uFFFD"}:CLOSE_BLOCK_DEFER:${"\uFFFD*4:3\uFFFD"}:START_BLOCK_PLACEHOLDER: before${"\uFFFD#1:3\uFFFD"}:START_TAG_DIV:placeholder${"\uFFFD/#1:3\uFFFD"}:CLOSE_TAG_DIV:after ${"\uFFFD/*4:3\uFFFD"}:CLOSE_BLOCK_PLACEHOLDER:${"\uFFFD*3:2\uFFFD"}:START_BLOCK_LOADING: before${"\uFFFD#1:2\uFFFD"}:START_TAG_BUTTON:loading${"\uFFFD/#1:2\uFFFD"}:CLOSE_TAG_BUTTON:after ${"\uFFFD/*3:2\uFFFD"}:CLOSE_BLOCK_LOADING:${"\uFFFD*5:4\uFFFD"}:START_BLOCK_ERROR: before${"\uFFFD#1:4\uFFFD"}:START_HEADING_LEVEL1:error${"\uFFFD/#1:4\uFFFD"}:CLOSE_HEADING_LEVEL1:after ${"\uFFFD/*5:4\uFFFD"}:CLOSE_BLOCK_ERROR:`; } return [i18n_0]; diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/blocks/for_template.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/blocks/for_template.js index 780430fdb91f..78935f74baea 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/blocks/for_template.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/blocks/for_template.js @@ -25,7 +25,7 @@ export class MyApp { /** * @suppress {msgDescriptions} */ - const $MSG_ID_WITH_SUFFIX$ = goog.getMsg(" Content: {$startBlockFor} before{$startTagSpan}middle{$closeTagSpan}after {$closeBlockFor}{$startBlockEmpty} before{$startTagDiv}empty{$closeTagDiv}after {$closeBlockEmpty}! ", { + const $MSG_ID_WITH_SUFFIX$ = /* @ts-ignore */ goog.getMsg(" Content: {$startBlockFor} before{$startTagSpan}middle{$closeTagSpan}after {$closeBlockFor}{$startBlockEmpty} before{$startTagDiv}empty{$closeTagDiv}after {$closeBlockEmpty}! ", { "closeBlockEmpty": "\uFFFD/*4:2\uFFFD", "closeBlockFor": "\uFFFD/*3:1\uFFFD", "closeTagDiv": "\uFFFD/#1:2\uFFFD", @@ -48,6 +48,7 @@ export class MyApp { }); i18n_0 = $MSG_ID_WITH_SUFFIX$; } else { + /* @ts-ignore */ i18n_0 = $localize` Content: ${"\uFFFD*3:1\uFFFD"}:START_BLOCK_FOR: before${"\uFFFD#1:1\uFFFD"}:START_TAG_SPAN:middle${"\uFFFD/#1:1\uFFFD"}:CLOSE_TAG_SPAN:after ${"\uFFFD/*3:1\uFFFD"}:CLOSE_BLOCK_FOR:${"\uFFFD*4:2\uFFFD"}:START_BLOCK_EMPTY: before${"\uFFFD#1:2\uFFFD"}:START_TAG_DIV:empty${"\uFFFD/#1:2\uFFFD"}:CLOSE_TAG_DIV:after ${"\uFFFD/*4:2\uFFFD"}:CLOSE_BLOCK_EMPTY:! `; } return [i18n_0]; diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/blocks/switch_template.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/blocks/switch_template.js index 1de149232202..44b3dd58303d 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/blocks/switch_template.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/blocks/switch_template.js @@ -33,7 +33,7 @@ export class MyApp { /** * @suppress {msgDescriptions} */ - const $MSG_ID_WITH_SUFFIX$ = goog.getMsg(" Content: {$startBlockCase}before{$startTagSpan}zero{$closeTagSpan}after{$closeBlockCase}{$startBlockCase_1}before{$startTagDiv}one{$closeTagDiv}after{$closeBlockCase}{$startBlockDefault}before{$startTagButton}otherwise{$closeTagButton}after{$closeBlockDefault}", { + const $MSG_ID_WITH_SUFFIX$ = /* @ts-ignore */ goog.getMsg(" Content: {$startBlockCase}before{$startTagSpan}zero{$closeTagSpan}after{$closeBlockCase}{$startBlockCase_1}before{$startTagDiv}one{$closeTagDiv}after{$closeBlockCase}{$startBlockDefault}before{$startTagButton}otherwise{$closeTagButton}after{$closeBlockDefault}", { "closeBlockCase": "[\uFFFD/*2:1\uFFFD|\uFFFD/*3:2\uFFFD]", "closeBlockDefault": "\uFFFD/*4:3\uFFFD", "closeTagButton": "\uFFFD/#1:3\uFFFD", @@ -62,6 +62,7 @@ export class MyApp { }); i18n_0 = $MSG_ID_WITH_SUFFIX$; } else { + /* @ts-ignore */ i18n_0 = $localize` Content: ${"\uFFFD*2:1\uFFFD"}:START_BLOCK_CASE:before${"\uFFFD#1:1\uFFFD"}:START_TAG_SPAN:zero${"\uFFFD/#1:1\uFFFD"}:CLOSE_TAG_SPAN:after${"[\uFFFD/*2:1\uFFFD|\uFFFD/*3:2\uFFFD]"}:CLOSE_BLOCK_CASE:${"\uFFFD*3:2\uFFFD"}:START_BLOCK_CASE_1:before${"\uFFFD#1:2\uFFFD"}:START_TAG_DIV:one${"\uFFFD/#1:2\uFFFD"}:CLOSE_TAG_DIV:after${"[\uFFFD/*2:1\uFFFD|\uFFFD/*3:2\uFFFD]"}:CLOSE_BLOCK_CASE:${"\uFFFD*4:3\uFFFD"}:START_BLOCK_DEFAULT:before${"\uFFFD#1:3\uFFFD"}:START_TAG_BUTTON:otherwise${"\uFFFD/#1:3\uFFFD"}:CLOSE_TAG_BUTTON:after${"\uFFFD/*4:3\uFFFD"}:CLOSE_BLOCK_DEFAULT:`; } i18n_0 = $r3$.ɵɵi18nPostprocess(i18n_0); diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/element_attributes/invalid_i18n_meta.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/element_attributes/invalid_i18n_meta.js index 8a9a5db2c27c..3bf281f448c5 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/element_attributes/invalid_i18n_meta.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/element_attributes/invalid_i18n_meta.js @@ -4,9 +4,10 @@ if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { /** * @suppress {msgDescriptions} */ - const $MSG_EXTERNAL_ID_WITH_INVALID_CHARS$$APP_SPEC_TS_1$ = goog.getMsg("Element title"); + const $MSG_EXTERNAL_ID_WITH_INVALID_CHARS$$APP_SPEC_TS_1$ = /* @ts-ignore */ goog.getMsg("Element title"); $I18N_0$ = $MSG_EXTERNAL_ID_WITH_INVALID_CHARS$$APP_SPEC_TS_1$; } else { + /* @ts-ignore */ $I18N_0$ = $localize`:@@ID.WITH.INVALID.CHARS:Element title`; } @@ -17,8 +18,9 @@ if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { /** * @suppress {msgDescriptions} */ - const $MSG_EXTERNAL_ID_WITH_INVALID_CHARS_2$$APP_SPEC_TS_4$ = goog.getMsg(" Some content "); + const $MSG_EXTERNAL_ID_WITH_INVALID_CHARS_2$$APP_SPEC_TS_4$ = /* @ts-ignore */ goog.getMsg(" Some content "); $I18N_2$ = $MSG_EXTERNAL_ID_WITH_INVALID_CHARS_2$$APP_SPEC_TS_4$; } else { + /* @ts-ignore */ $I18N_2$ = $localize`:@@ID.WITH.INVALID.CHARS.2: Some content `; } diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/element_attributes/meaning_description_template.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/element_attributes/meaning_description_template.js index e83ba1c87571..596e11504097 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/element_attributes/meaning_description_template.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/element_attributes/meaning_description_template.js @@ -12,9 +12,10 @@ consts: /** * @desc [BACKUP_${MESSAGE}_ID:idH]`desc */ - const $MSG_EXTERNAL_idG$$APP_SPEC_TS_24$ = goog.getMsg("Title G"); + const $MSG_EXTERNAL_idG$$APP_SPEC_TS_24$ = /* @ts-ignore */ goog.getMsg("Title G"); $i18n_23$ = $MSG_EXTERNAL_idG$$APP_SPEC_TS_24$; } else { + /* @ts-ignore */ $i18n_23$ = $localize`:[BACKUP_$\{MESSAGE}_ID\:idH]\`desc@@idG:Title G`; } @@ -26,9 +27,10 @@ consts: /** * @desc Some text \' [BACKUP_MESSAGE_ID: xxx] */ - const $MSG_EXTERNAL_idG$$APP_SPEC_TS_21$ = goog.getMsg("Content H"); + const $MSG_EXTERNAL_idG$$APP_SPEC_TS_21$ = /* @ts-ignore */ goog.getMsg("Content H"); $i18n_7$ = $MSG_EXTERNAL_idG$$APP_SPEC_TS_21$; } else { + /* @ts-ignore */ $i18n_7$ = $localize`:Some text \\' [BACKUP_MESSAGE_ID\: xxx]:Content H`; } diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/icu_logic/attribute_interpolation.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/icu_logic/attribute_interpolation.js index c755cd012fc4..76c1662f6448 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/icu_logic/attribute_interpolation.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/icu_logic/attribute_interpolation.js @@ -4,9 +4,10 @@ consts: () => { /** * @suppress {msgDescriptions} */ - const $MSG_EXTERNAL_6301050568345677976__ATTRIBUTE_INTERPOLATION_TS_2$ = goog.getMsg("{VAR_SELECT, select, other {{START_TAG_SPAN}foo{CLOSE_TAG_SPAN}}}"); + const $MSG_EXTERNAL_6301050568345677976__ATTRIBUTE_INTERPOLATION_TS_2$ = /* @ts-ignore */ goog.getMsg("{VAR_SELECT, select, other {{START_TAG_SPAN}foo{CLOSE_TAG_SPAN}}}"); $i18n_1$ = $MSG_EXTERNAL_6301050568345677976__ATTRIBUTE_INTERPOLATION_TS_2$; } else { + /* @ts-ignore */ $i18n_1$ = $localize`{VAR_SELECT, select, other {{START_TAG_SPAN}foo{CLOSE_TAG_SPAN}}}`; } $i18n_1$ = $r3$.ɵɵi18nPostprocess($i18n_1$, { @@ -19,9 +20,10 @@ consts: () => { /** * @suppress {msgDescriptions} */ - const $MSG_EXTERNAL_369205108016154659__ATTRIBUTE_INTERPOLATION_TS_4$ = goog.getMsg("{VAR_SELECT, select, other {{INTERPOLATION}-{INTERPOLATION}}}"); + const $MSG_EXTERNAL_369205108016154659__ATTRIBUTE_INTERPOLATION_TS_4$ = /* @ts-ignore */ goog.getMsg("{VAR_SELECT, select, other {{INTERPOLATION}-{INTERPOLATION}}}"); $i18n_3$ = $MSG_EXTERNAL_369205108016154659__ATTRIBUTE_INTERPOLATION_TS_4$; } else { + /* @ts-ignore */ $i18n_3$ = $localize`{VAR_SELECT, select, other {{INTERPOLATION}-{INTERPOLATION}}}`; } $i18n_3$ = $r3$.ɵɵi18nPostprocess($i18n_3$, { @@ -33,7 +35,7 @@ consts: () => { /** * @suppress {msgDescriptions} */ - const $MSG_EXTERNAL_6009429127580785009__ATTRIBUTE_INTERPOLATION_TS_5$ = goog.getMsg( + const $MSG_EXTERNAL_6009429127580785009__ATTRIBUTE_INTERPOLATION_TS_5$ = /* @ts-ignore */ goog.getMsg( "{$startTagSpan}{$closeTagSpan}{$startTagSpan_1}{$icu}{$closeTagSpan}{$startTagSpan_1}{$icu_1}{$closeTagSpan}", { "closeTagSpan": "[\uFFFD/#2\uFFFD|\uFFFD/#3\uFFFD|\uFFFD/#4\uFFFD]", @@ -52,6 +54,7 @@ consts: () => { }); $i18n_0$ = $MSG_EXTERNAL_6009429127580785009__ATTRIBUTE_INTERPOLATION_TS_5$; } else { + /* @ts-ignore */ $i18n_0$ = $localize`${"\uFFFD#2\uFFFD"}:START_TAG_SPAN:${"[\uFFFD/#2\uFFFD|\uFFFD/#3\uFFFD|\uFFFD/#4\uFFFD]"}:CLOSE_TAG_SPAN:${"[\uFFFD#3\uFFFD|\uFFFD#4\uFFFD]"}:START_TAG_SPAN_1:${$i18n_1$}:ICU@@6051755734147382484:${"[\uFFFD/#2\uFFFD|\uFFFD/#3\uFFFD|\uFFFD/#4\uFFFD]"}:CLOSE_TAG_SPAN:${"[\uFFFD#3\uFFFD|\uFFFD#4\uFFFD]"}:START_TAG_SPAN_1:${$i18n_3$}:ICU_1@@7593934392904803263:${"[\uFFFD/#2\uFFFD|\uFFFD/#3\uFFFD|\uFFFD/#4\uFFFD]"}:CLOSE_TAG_SPAN:`; } $i18n_0$ = $r3$.ɵɵi18nPostprocess($i18n_0$); diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/icu_logic/escape_quotes.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/icu_logic/escape_quotes.js index 2ee89dde2b96..b80bfa75aead 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/icu_logic/escape_quotes.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/icu_logic/escape_quotes.js @@ -3,12 +3,13 @@ if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { /** * @suppress {msgDescriptions} */ - const $MSG_EXTERNAL_4166854826696768832$$APP_SPEC_TS_0$ = goog.getMsg("{VAR_SELECT, select, single {'single quotes'} double {\"double quotes\"} other {other}}"); + const $MSG_EXTERNAL_4166854826696768832$$APP_SPEC_TS_0$ = /* @ts-ignore */ goog.getMsg("{VAR_SELECT, select, single {'single quotes'} double {\"double quotes\"} other {other}}"); $I18N_0$ = $MSG_EXTERNAL_4166854826696768832$$APP_SPEC_TS_0$; } else { + /* @ts-ignore */ $I18N_0$ = $localize `{VAR_SELECT, select, single {'single quotes'} double {"double quotes"} other {other}}`; } $I18N_0$ = $r3$.ɵɵi18nPostprocess($I18N_0$, { "VAR_SELECT": "\uFFFD0\uFFFD" -}); \ No newline at end of file +}); diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/icu_logic/root_icu_with_elements.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/icu_logic/root_icu_with_elements.js index c2790e592226..8b8a15625a6d 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/icu_logic/root_icu_with_elements.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/icu_logic/root_icu_with_elements.js @@ -4,7 +4,7 @@ consts: () => { /** * @desc someText1 */ - const $MSG_EXTERNAL_4505060179465988919ICU_WHITESPACE_TS_1$ = goog.getMsg("{VAR_SELECT, select, WEBSITE {{START_TAG_STRONG}someText{CLOSE_TAG_STRONG}\n }}"); + const $MSG_EXTERNAL_4505060179465988919ICU_WHITESPACE_TS_1$ = /* @ts-ignore */ goog.getMsg("{VAR_SELECT, select, WEBSITE {{START_TAG_STRONG}someText{CLOSE_TAG_STRONG}\n }}"); i18n_0 = $MSG_EXTERNAL_4505060179465988919ICU_WHITESPACE_TS_1$; } else { … @@ -14,7 +14,7 @@ consts: () => { /** * @suppress {msgDescriptions} */ - const $MSG_EXTERNAL_4505060179465988919ICU_WHITESPACE_TS_3$ = goog.getMsg("{VAR_SELECT, select, WEBSITE {{START_TAG_STRONG}someText{CLOSE_TAG_STRONG}\n }}"); + const $MSG_EXTERNAL_4505060179465988919ICU_WHITESPACE_TS_3$ = /* @ts-ignore */ goog.getMsg("{VAR_SELECT, select, WEBSITE {{START_TAG_STRONG}someText{CLOSE_TAG_STRONG}\n }}"); i18n_1 = $MSG_EXTERNAL_4505060179465988919ICU_WHITESPACE_TS_3$; } else { … diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/icu_logic/shared_placeholder.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/icu_logic/shared_placeholder.js index 4cea015bd35c..f50ae693f7ba 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/icu_logic/shared_placeholder.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/icu_logic/shared_placeholder.js @@ -21,10 +21,11 @@ consts: () => { /** * @suppress {msgDescriptions} */ - const $MSG_APP_SPEC_TS_1$ = goog.getMsg("{VAR_SELECT, select, male {male} female {female} other {other}}"); + const $MSG_APP_SPEC_TS_1$ = /* @ts-ignore */ goog.getMsg("{VAR_SELECT, select, male {male} female {female} other {other}}"); $I18N_1$ = $MSG_APP_SPEC_TS_1$; } else { + /* @ts-ignore */ $I18N_1$ = $localize `{VAR_SELECT, select, male {male} female {female} other {other}}`; } $I18N_1$ = $r3$.ɵɵi18nPostprocess($I18N_1$, { @@ -36,10 +37,11 @@ consts: () => { /** * @suppress {msgDescriptions} */ - const $MSG_APP_SPEC_TS_2$ = goog.getMsg("{VAR_SELECT, select, male {male} female {female} other {other}}"); + const $MSG_APP_SPEC_TS_2$ = /* @ts-ignore */ goog.getMsg("{VAR_SELECT, select, male {male} female {female} other {other}}"); $I18N_2$ = $MSG_APP_SPEC_TS_2$; } else { + /* @ts-ignore */ $I18N_2$ = $localize `{VAR_SELECT, select, male {male} female {female} other {other}}`; } $I18N_2$ = $r3$.ɵɵi18nPostprocess($I18N_2$, { @@ -51,10 +53,11 @@ consts: () => { /** * @suppress {msgDescriptions} */ - const $MSG_APP_SPEC_TS__4$ = goog.getMsg("{VAR_SELECT, select, male {male} female {female} other {other}}"); + const $MSG_APP_SPEC_TS__4$ = /* @ts-ignore */ goog.getMsg("{VAR_SELECT, select, male {male} female {female} other {other}}"); $I18N_4$ = $MSG_APP_SPEC_TS__4$; } else { + /* @ts-ignore */ $I18N_4$ = $localize `{VAR_SELECT, select, male {male} female {female} other {other}}`; } $I18N_4$ = $r3$.ɵɵi18nPostprocess($I18N_4$, { @@ -66,7 +69,7 @@ consts: () => { /** * @suppress {msgDescriptions} */ - const $MSG_APP_SPEC_TS_0$ = goog.getMsg(" {$icu} {$startTagDiv} {$icu} {$closeTagDiv}{$startTagDiv_1} {$icu} {$closeTagDiv}", { + const $MSG_APP_SPEC_TS_0$ = /* @ts-ignore */ goog.getMsg(" {$icu} {$startTagDiv} {$icu} {$closeTagDiv}{$startTagDiv_1} {$icu} {$closeTagDiv}", { "closeTagDiv": "[\uFFFD/#2\uFFFD|\uFFFD/#1:1\uFFFD\uFFFD/*3:1\uFFFD]", "icu": "\uFFFDI18N_EXP_ICU\uFFFD", "startTagDiv": "\uFFFD#2\uFFFD", @@ -82,6 +85,7 @@ consts: () => { $I18N_0$ = $MSG_APP_SPEC_TS_0$; } else { + /* @ts-ignore */ $I18N_0$ = $localize ` ${"\uFFFDI18N_EXP_ICU\uFFFD"}:ICU@@7670372064920373295: ${"\uFFFD#2\uFFFD"}:START_TAG_DIV: ${"\uFFFDI18N_EXP_ICU\uFFFD"}:ICU@@7670372064920373295: ${"[\uFFFD/#2\uFFFD|\uFFFD/#1:1\uFFFD\uFFFD/*3:1\uFFFD]"}:CLOSE_TAG_DIV:${"\uFFFD*3:1\uFFFD\uFFFD#1:1\uFFFD"}:START_TAG_DIV_1: ${"\uFFFDI18N_EXP_ICU\uFFFD"}:ICU@@7670372064920373295: ${"[\uFFFD/#2\uFFFD|\uFFFD/#1:1\uFFFD\uFFFD/*3:1\uFFFD]"}:CLOSE_TAG_DIV:`; } diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/localize_legacy_message_ids/legacy_disabled.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/localize_legacy_message_ids/legacy_disabled.js index 5cd67b37f498..bfb0faaab47d 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/localize_legacy_message_ids/legacy_disabled.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/localize_legacy_message_ids/legacy_disabled.js @@ -2,5 +2,6 @@ let $I18N_0$; if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { … } else { + /* @ts-ignore */ $I18N_0$ = $localize`Some Message`; } diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/localize_legacy_message_ids/legacy_enabled.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/localize_legacy_message_ids/legacy_enabled.js index fb51d031f489..6cbf4fa9b9e6 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/localize_legacy_message_ids/legacy_enabled.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/localize_legacy_message_ids/legacy_enabled.js @@ -4,10 +4,11 @@ consts: () => { /** * @suppress {msgDescriptions} */ - const $MSG_EXTERNAL_2908931752694090721$$LEGACY_ENABLED_TS_1$ = goog.getMsg( + const $MSG_EXTERNAL_2908931752694090721$$LEGACY_ENABLED_TS_1$ = /* @ts-ignore */ goog.getMsg( "Some & attribute"); $i18n_0$ = $MSG_EXTERNAL_2908931752694090721$$LEGACY_ENABLED_TS_1$; } else { + /* @ts-ignore */ $i18n_0$ = $localize`:␟82ec661067f503a3357ecc159b2128325e9208cd␟2908931752694090721:Some & attribute`; } let $i18n_2$; @@ -15,10 +16,11 @@ consts: () => { /** * @suppress {msgDescriptions} */ - const $MSG_EXTERNAL_2720535395337591908$$LEGACY_ENABLED_TS_13$ = goog.getMsg( + const $MSG_EXTERNAL_2720535395337591908$$LEGACY_ENABLED_TS_13$ = /* @ts-ignore */ goog.getMsg( "\""); $i18n_2$ = $MSG_EXTERNAL_2720535395337591908$$LEGACY_ENABLED_TS_13$; } else { + /* @ts-ignore */ $i18n_2$ = $localize`:␟5b30d888e99e7c6cfc6265f89c39b5921805cd2e␟2720535395337591908:"`; } let $i18n_4$; @@ -26,10 +28,11 @@ consts: () => { /** * @suppress {msgDescriptions} */ - const $MSG_EXTERNAL_3600934704948217447$$LEGACY_ENABLED_TS_15$ = goog.getMsg( + const $MSG_EXTERNAL_3600934704948217447$$LEGACY_ENABLED_TS_15$ = /* @ts-ignore */ goog.getMsg( "\"\""); $i18n_4$ = $MSG_EXTERNAL_3600934704948217447$$LEGACY_ENABLED_TS_15$; } else { + /* @ts-ignore */ $i18n_4$ = $localize`:␟bdfdbea9161864191756930161fd41b8bc980fde␟3600934704948217447:""`; } let $i18n_6$; @@ -37,11 +40,12 @@ consts: () => { /** * @suppress {msgDescriptions} */ - const $MSG_EXTERNAL_2334195497629636162$$LEGACY_ENABLED_TS_5$ = goog.getMsg( + const $MSG_EXTERNAL_2334195497629636162$$LEGACY_ENABLED_TS_5$ = /* @ts-ignore */ goog.getMsg( "Some & {$interpolation} attribute", {"interpolation": "\uFFFD0\uFFFD"}, {original_code: {"interpolation": "{{'interpolated'}}"}}); $i18n_6$ = $MSG_EXTERNAL_2334195497629636162$$LEGACY_ENABLED_TS_5$; } else { + /* @ts-ignore */ $i18n_6$ = $localize`:␟57ebd20267116c04cc1dbd7be0b73bf56484f45d␟2334195497629636162:Some & ${"\uFFFD0\uFFFD"}:INTERPOLATION: attribute`; } let $i18n_8$; @@ -49,10 +53,11 @@ consts: () => { /** * @suppress {msgDescriptions} */ - const $MSG_EXTERNAL_4700340487900776701$$LEGACY_ENABLED_TS_3$ = goog.getMsg( + const $MSG_EXTERNAL_4700340487900776701$$LEGACY_ENABLED_TS_3$ = /* @ts-ignore */ goog.getMsg( "Some & message"); $i18n_8$ = $MSG_EXTERNAL_4700340487900776701$$LEGACY_ENABLED_TS_3$; } else { + /* @ts-ignore */ $i18n_8$ = $localize`:␟10adaf0ad7b8ba40200cd3c0e7c8d0f13280d522␟4700340487900776701:Some & message`; } let $i18n_10$; @@ -60,11 +65,12 @@ consts: () => { /** * @suppress {msgDescriptions} */ - const $MSG_EXTERNAL_3204054277547499090$$LEGACY_ENABLED_TS_7$ = goog.getMsg( + const $MSG_EXTERNAL_3204054277547499090$$LEGACY_ENABLED_TS_7$ = /* @ts-ignore */ goog.getMsg( "Some & {$interpolation} message", {"interpolation": "\uFFFD0\uFFFD"}, {original_code: {"interpolation": "{{'interpolated' }}"}}); $i18n_10$ = $MSG_EXTERNAL_3204054277547499090$$LEGACY_ENABLED_TS_7$; } else { + /* @ts-ignore */ $i18n_10$ = $localize`:␟28d558ca32556f1da67a333e3dada321a97212cd␟3204054277547499090:Some & ${"\uFFFD0\uFFFD"}:INTERPOLATION: message`; } let $i18n_12$; @@ -72,10 +78,11 @@ consts: () => { /** * @suppress {msgDescriptions} */ - const $MSG_EXTERNAL_2406634758623728945$$LEGACY_ENABLED_TS_9$ = goog.getMsg( + const $MSG_EXTERNAL_2406634758623728945$$LEGACY_ENABLED_TS_9$ = /* @ts-ignore */ goog.getMsg( "&"); $i18n_12$ = $MSG_EXTERNAL_2406634758623728945$$LEGACY_ENABLED_TS_9$; } else { + /* @ts-ignore */ $i18n_12$ = $localize`:␟0b3dff7b9382b6217ac97c99f9b04df04381bfdd␟2406634758623728945:&`; } let $i18n_14$; @@ -83,14 +90,15 @@ consts: () => { /** * @suppress {msgDescriptions} */ - const $MSG_EXTERNAL_4156372478368653226$$LEGACY_ENABLED_TS_11$ = goog.getMsg( + const $MSG_EXTERNAL_4156372478368653226$$LEGACY_ENABLED_TS_11$ = /* @ts-ignore */ goog.getMsg( "&\""); $i18n_14$ = $MSG_EXTERNAL_4156372478368653226$$LEGACY_ENABLED_TS_11$; } else { + /* @ts-ignore */ $i18n_14$ = $localize`:␟25b7cbf210e59a931423097cb7f2e1b72991a687␟4156372478368653226:&"`; } return [$i18n_8$, $i18n_10$, $i18n_12$, $i18n_14$, ["title", $i18n_6$], ["title", $i18n_0$], [6, "title"], ["title", $i18n_2$], ["title", $i18n_4$]]; -}, +}, template: function MyComponent_Template(rf, ctx) { if (rf & 1) { i0.ɵɵelement(0, "div", 5); diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/namespaces/foreign_object.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/namespaces/foreign_object.js index 4f4ea3a0eadb..02cc7c69d344 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/namespaces/foreign_object.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/namespaces/foreign_object.js @@ -5,7 +5,7 @@ consts: () => { /** * @suppress {msgDescriptions} */ - const $MSG_EXTERNAL_7128002169381370313$$APP_SPEC_TS_1$ = goog.getMsg("{$startTagXhtmlDiv} Count: {$startTagXhtmlSpan}5{$closeTagXhtmlSpan}{$closeTagXhtmlDiv}", { + const $MSG_EXTERNAL_7128002169381370313$$APP_SPEC_TS_1$ = /* @ts-ignore */ goog.getMsg("{$startTagXhtmlDiv} Count: {$startTagXhtmlSpan}5{$closeTagXhtmlSpan}{$closeTagXhtmlDiv}", { "closeTagXhtmlDiv": "\uFFFD/#3\uFFFD", "closeTagXhtmlSpan": "\uFFFD/#4\uFFFD", "startTagXhtmlDiv": "\uFFFD#3\uFFFD", @@ -21,6 +21,7 @@ consts: () => { $I18N_0$ = $MSG_EXTERNAL_7128002169381370313$$APP_SPEC_TS_1$; } else { + /* @ts-ignore */ $I18N_0$ = $localize `${"\uFFFD#3\uFFFD"}:START_TAG__XHTML_DIV: Count: ${"\uFFFD#4\uFFFD"}:START_TAG__XHTML_SPAN:5${"\uFFFD/#4\uFFFD"}:CLOSE_TAG__XHTML_SPAN:${"\uFFFD/#3\uFFFD"}:CLOSE_TAG__XHTML_DIV:`; } return [ diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/namespaces/namespaced_div.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/namespaces/namespaced_div.js index 9e31e57a0687..c9b1347646bc 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/namespaces/namespaced_div.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/namespaces/namespaced_div.js @@ -4,7 +4,7 @@ consts: () => { /** * @suppress {msgDescriptions} */ - const $MSG_EXTERNAL_7428861019045796010$$APP_SPEC_TS_1$ = goog.getMsg(" Count: {$startTagXhtmlSpan}5{$closeTagXhtmlSpan}", { + const $MSG_EXTERNAL_7428861019045796010$$APP_SPEC_TS_1$ = /* @ts-ignore */ goog.getMsg(" Count: {$startTagXhtmlSpan}5{$closeTagXhtmlSpan}", { "closeTagXhtmlSpan": "\uFFFD/#4\uFFFD", "startTagXhtmlSpan": "\uFFFD#4\uFFFD" }, { @@ -16,6 +16,7 @@ consts: () => { $I18N_0$ = $MSG_EXTERNAL_7428861019045796010$$APP_SPEC_TS_1$; } else { + /* @ts-ignore */ $I18N_0$ = $localize ` Count: ${"\uFFFD#4\uFFFD"}:START_TAG__XHTML_SPAN:5${"\uFFFD/#4\uFFFD"}:CLOSE_TAG__XHTML_SPAN:`; } return [ diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/nested_nodes/backtick_quotes.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/nested_nodes/backtick_quotes.js index 49d1375fab75..0390969e511d 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/nested_nodes/backtick_quotes.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/nested_nodes/backtick_quotes.js @@ -4,9 +4,10 @@ if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { /** * @suppress {msgDescriptions} */ - const $MSG_APP_SPEC_TS_1$ = goog.getMsg("`{$interpolation}`", { "interpolation": "\uFFFD0\uFFFD" }, { original_code: { "interpolation": "{{ count }}" } }); + const $MSG_APP_SPEC_TS_1$ = /* @ts-ignore */ goog.getMsg("`{$interpolation}`", { "interpolation": "\uFFFD0\uFFFD" }, { original_code: { "interpolation": "{{ count }}" } }); $I18N_0$ = $MSG_APP_SPEC_TS_1$; } else { + /* @ts-ignore */ $I18N_0$ = $localize `\`${"\uFFFD0\uFFFD"}:INTERPOLATION:\``; } diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/nested_nodes/escape_quotes.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/nested_nodes/escape_quotes.js index a9144938a1e0..b09a39f27c34 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/nested_nodes/escape_quotes.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/nested_nodes/escape_quotes.js @@ -4,9 +4,10 @@ if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { /** * @suppress {msgDescriptions} */ - const $MSG_EXTERNAL_4924931801512133405$$APP_SPEC_TS_0$ = goog.getMsg("Some text 'with single quotes', \"with double quotes\", `with backticks` and without quotes."); + const $MSG_EXTERNAL_4924931801512133405$$APP_SPEC_TS_0$ = /* @ts-ignore */ goog.getMsg("Some text 'with single quotes', \"with double quotes\", `with backticks` and without quotes."); $I18N_0$ = $MSG_EXTERNAL_4924931801512133405$$APP_SPEC_TS_0$; } else { + /* @ts-ignore */ $I18N_0$ = $localize `Some text 'with single quotes', "with double quotes", \`with backticks\` and without quotes.`; } diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/nested_nodes/named_interpolations.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/nested_nodes/named_interpolations.js index 241b27ae828e..bb0134a3420b 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/nested_nodes/named_interpolations.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/nested_nodes/named_interpolations.js @@ -7,7 +7,7 @@ consts: () => { /** * @suppress {msgDescriptions} */ - const $MSG_EXTERNAL_7597881511811528589$$APP_SPEC_TS_0$ = goog.getMsg(" Named interpolation: {$phA} Named interpolation with spaces: {$phB} ", { + const $MSG_EXTERNAL_7597881511811528589$$APP_SPEC_TS_0$ = /* @ts-ignore */ goog.getMsg(" Named interpolation: {$phA} Named interpolation with spaces: {$phB} ", { "phB": "\uFFFD1\uFFFD", "phA": "\uFFFD0\uFFFD" }, { @@ -19,6 +19,7 @@ consts: () => { $I18N_0$ = $MSG_EXTERNAL_7597881511811528589$$APP_SPEC_TS_0$; } else { + /* @ts-ignore */ $I18N_0$ = $localize ` Named interpolation: ${"\uFFFD0\uFFFD"}:PH_A: Named interpolation with spaces: ${"\uFFFD1\uFFFD"}:PH_B: `; } return [ diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/whitespace_preserving_mode/preserve_inner_content.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/whitespace_preserving_mode/preserve_inner_content.js index 20a5e764aef7..661446911d5c 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/whitespace_preserving_mode/preserve_inner_content.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/whitespace_preserving_mode/preserve_inner_content.js @@ -5,7 +5,7 @@ consts: () => { /** * @suppress {msgDescriptions} */ - const $MSG_EXTERNAL_963542717423364282$$APP_SPEC_TS_0$ = goog.getMsg("\n Some text\n {$startTagSpan}Text inside span{$closeTagSpan}\n ", { + const $MSG_EXTERNAL_963542717423364282$$APP_SPEC_TS_0$ = /* @ts-ignore */ goog.getMsg("\n Some text\n {$startTagSpan}Text inside span{$closeTagSpan}\n ", { "closeTagSpan": "\uFFFD/#3\uFFFD", "startTagSpan": "\uFFFD#3\uFFFD" }, { @@ -17,6 +17,7 @@ consts: () => { $I18N_0$ = $MSG_EXTERNAL_963542717423364282$$APP_SPEC_TS_0$; } else { + /* @ts-ignore */ $I18N_0$ = $localize ` Some text ${"\uFFFD#3\uFFFD"}:START_TAG_SPAN:Text inside span${"\uFFFD/#3\uFFFD"}:CLOSE_TAG_SPAN: diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_let/let_in_child_view_inside_i18n_template.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_let/let_in_child_view_inside_i18n_template.js index 16f58d8091a9..468fd670c1de 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_let/let_in_child_view_inside_i18n_template.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_let/let_in_child_view_inside_i18n_template.js @@ -22,7 +22,7 @@ $r3$.ɵɵdefineComponent({ /** * @suppress {msgDescriptions} */ - const $MSG_ID_WITH_SUFFIX$ = goog.getMsg("{$startTagNgTemplate}The result is {$interpolation}{$closeTagNgTemplate}", { + const $MSG_ID_WITH_SUFFIX$ = /* @ts-ignore */ goog.getMsg("{$startTagNgTemplate}The result is {$interpolation}{$closeTagNgTemplate}", { "closeTagNgTemplate": "\uFFFD/*3:1\uFFFD", "interpolation": "\uFFFD0:1\uFFFD", "startTagNgTemplate": "\uFFFD*3:1\uFFFD" @@ -35,6 +35,7 @@ $r3$.ɵɵdefineComponent({ }); $i18n_0$ = $MSG_ID_WITH_SUFFIX$; } else { + /* @ts-ignore */ $i18n_0$ = $localize `${"\uFFFD*3:1\uFFFD"}:START_TAG_NG_TEMPLATE:The result is ${"\uFFFD0:1\uFFFD"}:INTERPOLATION:${"\uFFFD/*3:1\uFFFD"}:CLOSE_TAG_NG_TEMPLATE:`; } return [$i18n_0$]; diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_let/let_in_i18n_and_child_view_template.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_let/let_in_i18n_and_child_view_template.js index 98e0418cc7a5..2a2e11f579c5 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_let/let_in_i18n_and_child_view_template.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_let/let_in_i18n_and_child_view_template.js @@ -22,7 +22,7 @@ $r3$.ɵɵdefineComponent({ /** * @suppress {msgDescriptions} */ - const $MSG_ID_WITH_SUFFIX$ = goog.getMsg(" The result is {$interpolation} {$startTagNgTemplate}To repeat, the result is {$interpolation}{$closeTagNgTemplate}", { + const $MSG_ID_WITH_SUFFIX$ = /* @ts-ignore */ goog.getMsg(" The result is {$interpolation} {$startTagNgTemplate}To repeat, the result is {$interpolation}{$closeTagNgTemplate}", { "closeTagNgTemplate": "\uFFFD/*3:1\uFFFD", "interpolation": "[\uFFFD0\uFFFD|\uFFFD0:1\uFFFD]", "startTagNgTemplate": "\uFFFD*3:1\uFFFD" @@ -35,6 +35,7 @@ $r3$.ɵɵdefineComponent({ }); $i18n_0$ = $MSG_ID_WITH_SUFFIX$; } else { + /* @ts-ignore */ $i18n_0$ = $localize ` The result is ${"[\uFFFD0\uFFFD|\uFFFD0:1\uFFFD]"}:INTERPOLATION: ${"\uFFFD*3:1\uFFFD"}:START_TAG_NG_TEMPLATE:To repeat, the result is ${"[\uFFFD0\uFFFD|\uFFFD0:1\uFFFD]"}:INTERPOLATION:${"\uFFFD/*3:1\uFFFD"}:CLOSE_TAG_NG_TEMPLATE:`; } $i18n_0$ = $r3$.ɵɵi18nPostprocess($i18n_0$); diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_let/let_in_i18n_template.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_let/let_in_i18n_template.js index 000760f8bc14..63a5395586e5 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_let/let_in_i18n_template.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_let/let_in_i18n_template.js @@ -8,13 +8,14 @@ $r3$.ɵɵdefineComponent({ /** * @suppress {msgDescriptions} */ - const $MSG_ID_WITH_SUFFIX$ = goog.getMsg(" The result is {$interpolation} ", { + const $MSG_ID_WITH_SUFFIX$ = /* @ts-ignore */ goog.getMsg(" The result is {$interpolation} ", { "interpolation": "\uFFFD0\uFFFD" }, { original_code: { "interpolation": "{{result}}" } }); $i18n_0$ = $MSG_ID_WITH_SUFFIX$; } else { + /* @ts-ignore */ $i18n_0$ = $localize ` The result is ${"\uFFFD0\uFFFD"}:INTERPOLATION: `; } return [$i18n_0$]; diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_let/let_preceded_by_i18n_template.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_let/let_preceded_by_i18n_template.js index 8d33e33bf122..92bb743bbc6a 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_let/let_preceded_by_i18n_template.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_let/let_preceded_by_i18n_template.js @@ -21,13 +21,14 @@ $r3$.ɵɵdefineComponent({ /** * @suppress {msgDescriptions} */ - const $MSG_ID_WITH_SUFFIX$ = goog.getMsg("Hello {$interpolation}", { + const $MSG_ID_WITH_SUFFIX$ = /* @ts-ignore */ goog.getMsg("Hello {$interpolation}", { "interpolation": "\uFFFD0\uFFFD" }, { original_code: { "interpolation": "{{value}}" } }); $i18n_0$ = $MSG_ID_WITH_SUFFIX$; } else { + /* @ts-ignore */ $i18n_0$ = $localize `Hello ${"\uFFFD0\uFFFD"}:INTERPOLATION:`; } return [$i18n_0$]; diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_listener/GOLDEN_PARTIAL.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_listener/GOLDEN_PARTIAL.js index 76d86d7b774c..b136d3e69968 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_listener/GOLDEN_PARTIAL.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_listener/GOLDEN_PARTIAL.js @@ -953,7 +953,8 @@ export declare class App { import { Component, Directive, model, signal } from '@angular/core'; import * as i0 from "@angular/core"; export class NgModelDirective { - ngModel = model.required(...(ngDevMode ? [{ debugName: "ngModel" }] : /* istanbul ignore next */ [])); + ngModel = model.required(/* @ts-ignore */ + ...(ngDevMode ? [{ debugName: "ngModel" }] : /* istanbul ignore next */ [])); static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "0.0.0-PLACEHOLDER", ngImport: i0, type: NgModelDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "0.0.0-PLACEHOLDER", type: NgModelDirective, isStandalone: true, selector: "[ngModel]", inputs: { ngModel: { classPropertyName: "ngModel", publicName: "ngModel", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { ngModel: "ngModelChange" }, ngImport: i0 }); } @@ -1005,7 +1006,8 @@ export declare class TestCmp { import { Component, Directive, model } from '@angular/core'; import * as i0 from "@angular/core"; export class NgModelDirective { - ngModel = model('', ...(ngDevMode ? [{ debugName: "ngModel" }] : /* istanbul ignore next */ [])); + ngModel = model('', /* @ts-ignore */ + ...(ngDevMode ? [{ debugName: "ngModel" }] : /* istanbul ignore next */ [])); static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "0.0.0-PLACEHOLDER", ngImport: i0, type: NgModelDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "0.0.0-PLACEHOLDER", type: NgModelDirective, isStandalone: true, selector: "[ngModel]", inputs: { ngModel: { classPropertyName: "ngModel", publicName: "ngModel", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { ngModel: "ngModelChange" }, ngImport: i0 }); } diff --git a/packages/compiler-cli/test/compliance/test_cases/signal_inputs/GOLDEN_PARTIAL.js b/packages/compiler-cli/test/compliance/test_cases/signal_inputs/GOLDEN_PARTIAL.js index 53d9ea5d5246..8787359935db 100644 --- a/packages/compiler-cli/test/compliance/test_cases/signal_inputs/GOLDEN_PARTIAL.js +++ b/packages/compiler-cli/test/compliance/test_cases/signal_inputs/GOLDEN_PARTIAL.js @@ -4,8 +4,10 @@ import { Directive, input } from '@angular/core'; import * as i0 from "@angular/core"; export class TestDir { - counter = input(0, ...(ngDevMode ? [{ debugName: "counter" }] : /* istanbul ignore next */ [])); - name = input.required(...(ngDevMode ? [{ debugName: "name" }] : /* istanbul ignore next */ [])); + counter = input(0, /* @ts-ignore */ + ...(ngDevMode ? [{ debugName: "counter" }] : /* istanbul ignore next */ [])); + name = input.required(/* @ts-ignore */ + ...(ngDevMode ? [{ debugName: "name" }] : /* istanbul ignore next */ [])); static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "0.0.0-PLACEHOLDER", ngImport: i0, type: TestDir, deps: [], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "0.0.0-PLACEHOLDER", type: TestDir, isStandalone: true, inputs: { counter: { classPropertyName: "counter", publicName: "counter", isSignal: true, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0 }); } @@ -31,8 +33,10 @@ export declare class TestDir { import { Component, input } from '@angular/core'; import * as i0 from "@angular/core"; export class TestComp { - counter = input(0, ...(ngDevMode ? [{ debugName: "counter" }] : /* istanbul ignore next */ [])); - name = input.required(...(ngDevMode ? [{ debugName: "name" }] : /* istanbul ignore next */ [])); + counter = input(0, /* @ts-ignore */ + ...(ngDevMode ? [{ debugName: "counter" }] : /* istanbul ignore next */ [])); + name = input.required(/* @ts-ignore */ + ...(ngDevMode ? [{ debugName: "name" }] : /* istanbul ignore next */ [])); static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "0.0.0-PLACEHOLDER", ngImport: i0, type: TestComp, deps: [], target: i0.ɵɵFactoryTarget.Component }); static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "0.0.0-PLACEHOLDER", type: TestComp, isStandalone: true, selector: "ng-component", inputs: { counter: { classPropertyName: "counter", publicName: "counter", isSignal: true, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: 'Works', isInline: true }); } @@ -63,7 +67,8 @@ function convertToBoolean(value) { return value === true || value !== ''; } export class TestDir { - counter = input(0, ...(ngDevMode ? [{ debugName: "counter" }] : /* istanbul ignore next */ [])); + counter = input(0, /* @ts-ignore */ + ...(ngDevMode ? [{ debugName: "counter" }] : /* istanbul ignore next */ [])); signalWithTransform = input(false, { ...(ngDevMode ? { debugName: "signalWithTransform" } : /* istanbul ignore next */ {}), transform: convertToBoolean }); signalWithTransformAndAlias = input(false, { ...(ngDevMode ? { debugName: "signalWithTransformAndAlias" } : /* istanbul ignore next */ {}), alias: 'publicNameSignal', transform: convertToBoolean }); decoratorInput = true; diff --git a/packages/compiler-cli/test/compliance/test_cases/signal_queries/GOLDEN_PARTIAL.js b/packages/compiler-cli/test/compliance/test_cases/signal_queries/GOLDEN_PARTIAL.js index a9a8c21f588a..1dae31ac0add 100644 --- a/packages/compiler-cli/test/compliance/test_cases/signal_queries/GOLDEN_PARTIAL.js +++ b/packages/compiler-cli/test/compliance/test_cases/signal_queries/GOLDEN_PARTIAL.js @@ -7,12 +7,18 @@ export class SomeToken { } const nonAnalyzableRefersToString = 'a, b, c'; export class TestDir { - query1 = viewChild('locatorA', ...(ngDevMode ? [{ debugName: "query1" }] : /* istanbul ignore next */ [])); - query2 = viewChildren('locatorB', ...(ngDevMode ? [{ debugName: "query2" }] : /* istanbul ignore next */ [])); - query3 = contentChild('locatorC', ...(ngDevMode ? [{ debugName: "query3" }] : /* istanbul ignore next */ [])); - query4 = contentChildren('locatorD', ...(ngDevMode ? [{ debugName: "query4" }] : /* istanbul ignore next */ [])); - query5 = viewChild(forwardRef(() => SomeToken), ...(ngDevMode ? [{ debugName: "query5" }] : /* istanbul ignore next */ [])); - query6 = viewChildren(SomeToken, ...(ngDevMode ? [{ debugName: "query6" }] : /* istanbul ignore next */ [])); + query1 = viewChild('locatorA', /* @ts-ignore */ + ...(ngDevMode ? [{ debugName: "query1" }] : /* istanbul ignore next */ [])); + query2 = viewChildren('locatorB', /* @ts-ignore */ + ...(ngDevMode ? [{ debugName: "query2" }] : /* istanbul ignore next */ [])); + query3 = contentChild('locatorC', /* @ts-ignore */ + ...(ngDevMode ? [{ debugName: "query3" }] : /* istanbul ignore next */ [])); + query4 = contentChildren('locatorD', /* @ts-ignore */ + ...(ngDevMode ? [{ debugName: "query4" }] : /* istanbul ignore next */ [])); + query5 = viewChild(forwardRef(() => SomeToken), /* @ts-ignore */ + ...(ngDevMode ? [{ debugName: "query5" }] : /* istanbul ignore next */ [])); + query6 = viewChildren(SomeToken, /* @ts-ignore */ + ...(ngDevMode ? [{ debugName: "query6" }] : /* istanbul ignore next */ [])); query7 = viewChild('locatorE', { ...(ngDevMode ? { debugName: "query7" } : /* istanbul ignore next */ {}), read: SomeToken }); query8 = contentChildren('locatorF, locatorG', { ...(ngDevMode ? { debugName: "query8" } : /* istanbul ignore next */ {}), descendants: true }); query9 = contentChildren(nonAnalyzableRefersToString, { ...(ngDevMode ? { debugName: "query9" } : /* istanbul ignore next */ {}), descendants: true }); @@ -50,10 +56,14 @@ export declare class TestDir { import { Component, contentChild, contentChildren, viewChild, viewChildren } from '@angular/core'; import * as i0 from "@angular/core"; export class TestComp { - query1 = viewChild('locatorA', ...(ngDevMode ? [{ debugName: "query1" }] : /* istanbul ignore next */ [])); - query2 = viewChildren('locatorB', ...(ngDevMode ? [{ debugName: "query2" }] : /* istanbul ignore next */ [])); - query3 = contentChild('locatorC', ...(ngDevMode ? [{ debugName: "query3" }] : /* istanbul ignore next */ [])); - query4 = contentChildren('locatorD', ...(ngDevMode ? [{ debugName: "query4" }] : /* istanbul ignore next */ [])); + query1 = viewChild('locatorA', /* @ts-ignore */ + ...(ngDevMode ? [{ debugName: "query1" }] : /* istanbul ignore next */ [])); + query2 = viewChildren('locatorB', /* @ts-ignore */ + ...(ngDevMode ? [{ debugName: "query2" }] : /* istanbul ignore next */ [])); + query3 = contentChild('locatorC', /* @ts-ignore */ + ...(ngDevMode ? [{ debugName: "query3" }] : /* istanbul ignore next */ [])); + query4 = contentChildren('locatorD', /* @ts-ignore */ + ...(ngDevMode ? [{ debugName: "query4" }] : /* istanbul ignore next */ [])); static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "0.0.0-PLACEHOLDER", ngImport: i0, type: TestComp, deps: [], target: i0.ɵɵFactoryTarget.Component }); static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "0.0.0-PLACEHOLDER", type: TestComp, isStandalone: true, selector: "ng-component", queries: [{ propertyName: "query3", first: true, predicate: ["locatorC"], descendants: true, isSignal: true }, { propertyName: "query4", predicate: ["locatorD"], isSignal: true }], viewQueries: [{ propertyName: "query1", first: true, predicate: ["locatorA"], descendants: true, isSignal: true }, { propertyName: "query2", predicate: ["locatorB"], descendants: true, isSignal: true }], ngImport: i0, template: 'Works', isInline: true }); } @@ -84,9 +94,11 @@ import { ContentChild, contentChild, Directive, ViewChild, viewChild } from '@an import * as i0 from "@angular/core"; export class TestDir { decoratorViewChild; - signalViewChild = viewChild('locator1', ...(ngDevMode ? [{ debugName: "signalViewChild" }] : /* istanbul ignore next */ [])); + signalViewChild = viewChild('locator1', /* @ts-ignore */ + ...(ngDevMode ? [{ debugName: "signalViewChild" }] : /* istanbul ignore next */ [])); decoratorContentChild; - signalContentChild = contentChild('locator2', ...(ngDevMode ? [{ debugName: "signalContentChild" }] : /* istanbul ignore next */ [])); + signalContentChild = contentChild('locator2', /* @ts-ignore */ + ...(ngDevMode ? [{ debugName: "signalContentChild" }] : /* istanbul ignore next */ [])); static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "0.0.0-PLACEHOLDER", ngImport: i0, type: TestDir, deps: [], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "0.0.0-PLACEHOLDER", type: TestDir, isStandalone: true, queries: [{ propertyName: "signalContentChild", first: true, predicate: ["locator2"], descendants: true, isSignal: true }, { propertyName: "decoratorContentChild", first: true, predicate: ["locator2"], descendants: true }], viewQueries: [{ propertyName: "signalViewChild", first: true, predicate: ["locator1"], descendants: true, isSignal: true }, { propertyName: "decoratorViewChild", first: true, predicate: ["locator1"], descendants: true }], ngImport: i0 }); } diff --git a/packages/compiler-cli/test/compliance/test_helpers/i18n_helpers.ts b/packages/compiler-cli/test/compliance/test_helpers/i18n_helpers.ts index bce436ac212d..d252e23daa4b 100644 --- a/packages/compiler-cli/test/compliance/test_helpers/i18n_helpers.ts +++ b/packages/compiler-cli/test/compliance/test_helpers/i18n_helpers.ts @@ -33,10 +33,11 @@ export function i18nMsg( let ${varName}; if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { ${i18nMsgClosureMeta(meta)} - const $MSG_EXTERNAL_${msgIndex}$ = goog.getMsg("${message}"${closurePlaceholders}${closureOptions}); + const $MSG_EXTERNAL_${msgIndex}$ = /* @ts-ignore */ goog.getMsg("${message}"${closurePlaceholders}${closureOptions}); ${varName} = $MSG_EXTERNAL_${msgIndex}$; } else { + /* @ts-ignore */ ${varName} = $localize \`${i18nMsgLocalizeMeta(meta)}${locMessageWithPlaceholders}\`; }`; } diff --git a/packages/compiler-cli/test/ngtsc/debug_transform_spec.ts b/packages/compiler-cli/test/ngtsc/debug_transform_spec.ts index b80b1bba944c..4fb520c9e37a 100644 --- a/packages/compiler-cli/test/ngtsc/debug_transform_spec.ts +++ b/packages/compiler-cli/test/ngtsc/debug_transform_spec.ts @@ -31,7 +31,7 @@ const minifiedProdBuildOptions = { }; function cleanNewLines(contents: string) { - return contents.replace(/\n/g, ' ').replace(/\s+/g, ' '); + return contents.replace(/\s*\n\s*/g, ' '); } runInEachFileSystem(() => { diff --git a/packages/compiler-cli/test/ngtsc/defer_spec.ts b/packages/compiler-cli/test/ngtsc/defer_spec.ts index 08f146695c19..ebd76e5436e9 100644 --- a/packages/compiler-cli/test/ngtsc/defer_spec.ts +++ b/packages/compiler-cli/test/ngtsc/defer_spec.ts @@ -16,7 +16,7 @@ import {NgtscTestEnvironment} from './env'; const testFiles = loadStandardTestFiles(); function cleanNewLines(contents: string) { - return contents.replace(/\n/g, ' ').replace(/\s+/g, ' '); + return contents.replace(/\s*\n\s*/g, ' '); } runInEachFileSystem(() => { @@ -687,7 +687,9 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); expect(jsContents).toContain('ɵɵdefer(1, 0, TestCmp_Defer_1_DepsFn)'); - expect(cleanNewLines(jsContents)).toContain('() => [/* @ts-ignore */ import("./cmp").then(m => m.Cmp)]'); + expect(cleanNewLines(jsContents)).toContain( + '() => [/* @ts-ignore */ import("./cmp").then(m => m.Cmp)]', + ); expect(jsContents).not.toContain('import { Cmp }'); }); diff --git a/packages/compiler-cli/test/ngtsc/local_compilation_spec.ts b/packages/compiler-cli/test/ngtsc/local_compilation_spec.ts index 5c0b0fb57ca6..26b9c15d2c20 100644 --- a/packages/compiler-cli/test/ngtsc/local_compilation_spec.ts +++ b/packages/compiler-cli/test/ngtsc/local_compilation_spec.ts @@ -17,7 +17,7 @@ import {NgtscTestEnvironment, TsConfigOptions} from './env'; const testFiles = loadStandardTestFiles(); function cleanNewLines(contents: string) { - return contents.replace(/\n/g, ' ').replace(/\s+/g, ' '); + return contents.replace(/\s*\n\s*/g, ' '); } runInEachFileSystem(() => { diff --git a/packages/compiler-cli/test/ngtsc/selectorless_spec.ts b/packages/compiler-cli/test/ngtsc/selectorless_spec.ts index 74f4419a93ab..89b7dd9b0676 100644 --- a/packages/compiler-cli/test/ngtsc/selectorless_spec.ts +++ b/packages/compiler-cli/test/ngtsc/selectorless_spec.ts @@ -13,7 +13,7 @@ import {NgtscTestEnvironment} from './env'; const testFiles = loadStandardTestFiles(); function cleanNewLines(contents: string) { - return contents.replace(/\n/g, ' ').replace(/\s+/g, ' '); + return contents.replace(/\s*\n\s*/g, ' '); } runInEachFileSystem(() => {