@@ -232,6 +232,125 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => {
232232 ) ;
233233 } ) ;
234234
235+ it ( 'detects template errors when an input becomes required or a selector is renamed on watch rebuild' , async ( ) => {
236+ harness . useTarget ( 'build' , {
237+ ...BASE_OPTIONS ,
238+ watch : true ,
239+ } ) ;
240+
241+ await harness . modifyFile ( 'tsconfig.json' , ( content ) => {
242+ const tsconfig = JSON . parse ( content ) ;
243+ tsconfig . compilerOptions = {
244+ ...tsconfig . compilerOptions ,
245+ isolatedModules : true ,
246+ } ;
247+
248+ return JSON . stringify ( tsconfig ) ;
249+ } ) ;
250+
251+ const goodChildComponentContents = `
252+ import { Component, input } from '@angular/core';
253+ @Component({
254+ selector: 'app-child',
255+ standalone: true,
256+ template: '<p>{{ label() }}</p>',
257+ })
258+ export class ChildComponent {
259+ label = input('');
260+ }
261+ ` ;
262+
263+ const requiredInputErrorText = `Required input 'label' from component ChildComponent must be specified.` ;
264+ const unknownElementErrorText = `'app-child' is not a known element` ;
265+
266+ await harness . writeFiles ( {
267+ 'src/app/child.component.ts' : goodChildComponentContents ,
268+ 'src/app/app.module.ts' : `
269+ import { NgModule } from '@angular/core';
270+ import { BrowserModule } from '@angular/platform-browser';
271+ import { AppComponent } from './app.component';
272+ @NgModule({
273+ imports: [
274+ BrowserModule,
275+ AppComponent,
276+ ],
277+ providers: [],
278+ bootstrap: [AppComponent]
279+ })
280+ export class AppModule { }
281+ ` ,
282+ 'src/app/app.component.ts' : `
283+ import { Component } from '@angular/core';
284+ import { ChildComponent } from './child.component';
285+ @Component({
286+ selector: 'app-root',
287+ standalone: true,
288+ imports: [ChildComponent],
289+ template: '<app-child />',
290+ })
291+ export class AppComponent {}
292+ ` ,
293+ } ) ;
294+
295+ await harness . executeWithCases (
296+ [
297+ async ( { result } ) => {
298+ expect ( result ?. success ) . toBeTrue ( ) ;
299+
300+ // Make input required using signal input.required() (which has the same TS .d.ts type InputSignal<string>)
301+ await harness . writeFile (
302+ 'src/app/child.component.ts' ,
303+ `
304+ import { Component, input } from '@angular/core';
305+ @Component({
306+ selector: 'app-child',
307+ standalone: true,
308+ template: '<p>{{ label() }}</p>',
309+ })
310+ export class ChildComponent {
311+ label = input.required<string>();
312+ }
313+ ` ,
314+ ) ;
315+ } ,
316+ async ( { result, logs } ) => {
317+ expect ( result ?. success ) . toBeFalse ( ) ;
318+ expectLog ( logs , requiredInputErrorText ) ;
319+
320+ // Revert required input and rename selector instead
321+ await harness . writeFile (
322+ 'src/app/child.component.ts' ,
323+ `
324+ import { Component, input } from '@angular/core';
325+ @Component({
326+ selector: 'app-child-renamed',
327+ standalone: true,
328+ template: '<p>{{ label() }}</p>',
329+ })
330+ export class ChildComponent {
331+ label = input('');
332+ }
333+ ` ,
334+ ) ;
335+ } ,
336+ async ( { result, logs } ) => {
337+ expect ( result ?. success ) . toBeFalse ( ) ;
338+ expectNoLog ( logs , requiredInputErrorText ) ;
339+ expectLog ( logs , unknownElementErrorText ) ;
340+
341+ // Revert back to valid child component
342+ await harness . writeFile ( 'src/app/child.component.ts' , goodChildComponentContents ) ;
343+ } ,
344+ ( { result, logs } ) => {
345+ expect ( result ?. success ) . toBeTrue ( ) ;
346+ expectNoLog ( logs , requiredInputErrorText ) ;
347+ expectNoLog ( logs , unknownElementErrorText ) ;
348+ } ,
349+ ] ,
350+ { outputLogsOnFailure : false } ,
351+ ) ;
352+ } ) ;
353+
235354 it ( 'detects cumulative block syntax errors' , async ( ) => {
236355 harness . useTarget ( 'build' , {
237356 ...BASE_OPTIONS ,
0 commit comments