angular/packages/core/schematics/migrations/control-flow-migration
Paul Gschwendtner b763059bdd build: migrate packages/core/schematics to ts_project (#61370)
Migrates `packages/core/schematics` to `ts_project`. As part of this,
this commit cleans up some of the mixed module types and tsconfigs in
the folder. A single tsconfig (and it's test variant) are now used.

For the shipped schematics, we explicitly use the `.cjs` extension, so
that the bundles are properly recognized as CommonJS; even if they are
part of the `type: module` `@angular/core` package.

The `package.json` with `type: commonjs` is removed from
`packages/core/schematics` as it's no longer needed given the explicit
extension & caused issues as schematics are compiled with ESM but are
only later bundled for shipping & some tests as ESM.

PR Close #61370
2025-05-16 11:02:07 +00:00
..
BUILD.bazel build: migrate packages/core/schematics to ts_project (#61370) 2025-05-16 11:02:07 +00:00
cases.ts refactor(core): run the control flow migration during ng update (#60492) 2025-03-28 15:46:41 +00:00
fors.ts refactor(core): run the control flow migration during ng update (#60492) 2025-03-28 15:46:41 +00:00
identifier-lookup.ts refactor(core): run the control flow migration during ng update (#60492) 2025-03-28 15:46:41 +00:00
ifs.ts refactor(core): run the control flow migration during ng update (#60492) 2025-03-28 15:46:41 +00:00
index.ts refactor(core): run the control flow migration during ng update (#60492) 2025-03-28 15:46:41 +00:00
migration.ts refactor(core): run the control flow migration during ng update (#60492) 2025-03-28 15:46:41 +00:00
README.md refactor(core): run the control flow migration during ng update (#60492) 2025-03-28 15:46:41 +00:00
schema.json refactor(core): run the control flow migration during ng update (#60492) 2025-03-28 15:46:41 +00:00
switches.ts refactor(core): run the control flow migration during ng update (#60492) 2025-03-28 15:46:41 +00:00
types.ts refactor(core): run the control flow migration during ng update (#60492) 2025-03-28 15:46:41 +00:00
util.ts refactor(core): run the control flow migration during ng update (#60492) 2025-03-28 15:46:41 +00:00

Control Flow Syntax migration

Angular v17 introduces a new control flow syntax. This migration replaces the existing usages of *ngIf, *ngFor, and *ngSwitch to their equivalent block syntax. Existing ng-templates are preserved in case they are used elsewhere in the template. It has the following option:

  • path - Relative path within the project that the migration should apply to. Can be used to migrate specific sub-directories individually. Defaults to the project root.

Before

import {Component} from '@angular/core';

@Component({
  template: `<div><span *ngIf="show">Content here</span></div>`
})
export class MyComp {
  show = false;
}

After

import {Component} from '@angular/core';

@Component({
  template: `<div>@if (show) {<span>Content here</span>}</div>`
})
export class MyComp {
  show = false
}