angular-cn/packages/core/schematics/migrations/template-var-assignment
Paul Gschwendtner d43c30688a fix(core): avoid migration error when non-existent symbol is imported (#36367)
In rare cases a project with configured `rootDirs` that has imports to
non-existent identifiers could fail in the migration.

This happens because based on the application code, the migration could
end up trying to resolve the `ts.Symbol` of such non-existent
identifiers. This isn't a problem usually, but due to a upstream bug
in the TypeScript compiler, a runtime error is thrown.

This is because TypeScript is unable to compute a relative path from the
originating source file to the imported source file which _should_
provide the non-existent identifier. An issue for this has been reported
upstream: https://github.com/microsoft/TypeScript/issues/37731. The
issue only surfaces since our migrations don't provide an absolute base
path that is used for resolving the root directories.

To fix this, we ensure that we never use relative paths when parsing
tsconfig files. More details can be found in the TS issue.

Fixes #36346.

PR Close #36367
2020-04-06 13:21:54 -07:00
..
angular refactor(core): template-var-assignment migration incorrectly warns (#30026) 2019-04-22 11:16:19 -07:00
BUILD.bazel refactor(core): move google3 migration rules into single directory (#30956) 2019-07-23 15:52:40 -07:00
README.md refactor(core): polish failure messages for template-var-assignment schematic (#29708) 2019-04-08 09:46:57 -07:00
analyze_template.ts refactor(core): template-var-assignment migration incorrectly warns (#30026) 2019-04-22 11:16:19 -07:00
index.ts fix(core): avoid migration error when non-existent symbol is imported (#36367) 2020-04-06 13:21:54 -07:00

README.md

Assignments to template variables

With Ivy, assignments to template variables are no longer supported as template variables are effectively constants.

This means that assignments to template variables will break your application once Ivy is enabled by default. For example:

<button *ngFor="let option of options"
       (click)="option = 'newButtonText'">
  {{ option }}
</button>

In the example from above, a value is assigned to the option template variable on click. This will ultimately break your application and therefore the logic needs to be adjusted to not update the option variable, but rather the given element in the options array:

<button *ngFor="let option of options; let idx = index"
       (click)="options[idx] = 'newButtonText'">
  {{ option }}
</button>