angular-cn/packages/core/schematics/migrations/module-with-providers
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
..
BUILD.bazel feat(core): add ModuleWithProviders generic type migration (#33217) 2019-10-21 15:53:28 -04:00
README.md feat(core): add ModuleWithProviders generic type migration (#33217) 2019-10-21 15:53:28 -04:00
collector.ts feat(core): add ModuleWithProviders generic type migration (#33217) 2019-10-21 15:53:28 -04:00
index.ts fix(core): avoid migration error when non-existent symbol is imported (#36367) 2020-04-06 13:21:54 -07:00
transform.ts perf(ivy): reuse prior analysis work during incremental builds (#34288) 2019-12-12 13:11:45 -08:00
util.ts feat(core): add ModuleWithProviders generic type migration (#33217) 2019-10-21 15:53:28 -04:00

README.md

ModuleWithProviders migration

ModuleWithProviders type will not default to the any type for its generic in a future version of Angular. This migration adds a generic to any ModuleWithProvider types found.

Before

import { NgModule, ModuleWithProviders } from '@angular/core';

@NgModule({})
export class MyModule {
  static forRoot(): ModuleWithProviders {
    ngModule: MyModule
  }
}

After

import { NgModule, ModuleWithProviders } from '@angular/core';

@NgModule({})
export class MyModule {
  static forRoot(): ModuleWithProviders<MyModule> {
    ngModule: MyModule
  }
}