diff --git a/packages/compiler-cli/src/ngtsc/incremental/src/incremental.ts b/packages/compiler-cli/src/ngtsc/incremental/src/incremental.ts index e0ef06c463..1f466dc968 100644 --- a/packages/compiler-cli/src/ngtsc/incremental/src/incremental.ts +++ b/packages/compiler-cli/src/ngtsc/incremental/src/incremental.ts @@ -259,7 +259,7 @@ export class IncrementalCompilation implements IncrementalBuild; /** * All generated template type-checking files produced as part of this compilation, or `null` if diff --git a/packages/compiler-cli/src/ngtsc/incremental/test/BUILD.bazel b/packages/compiler-cli/src/ngtsc/incremental/test/BUILD.bazel index 333aff0605..77fb8e15f5 100644 --- a/packages/compiler-cli/src/ngtsc/incremental/test/BUILD.bazel +++ b/packages/compiler-cli/src/ngtsc/incremental/test/BUILD.bazel @@ -16,6 +16,7 @@ ts_library( "//packages/compiler-cli/src/ngtsc/incremental", "//packages/compiler-cli/src/ngtsc/perf", "//packages/compiler-cli/src/ngtsc/testing", + "//packages/compiler-cli/src/ngtsc/transform", "@npm//typescript", ], ) diff --git a/packages/compiler-cli/src/ngtsc/incremental/test/incremental_spec.ts b/packages/compiler-cli/src/ngtsc/incremental/test/incremental_spec.ts index 5eae81e0a1..1dd3edca02 100644 --- a/packages/compiler-cli/src/ngtsc/incremental/test/incremental_spec.ts +++ b/packages/compiler-cli/src/ngtsc/incremental/test/incremental_spec.ts @@ -10,6 +10,7 @@ import {absoluteFrom, getSourceFileOrError} from '../../file_system'; import {runInEachFileSystem} from '../../file_system/testing'; import {NOOP_PERF_RECORDER} from '../../perf'; import {makeProgram} from '../../testing'; +import {TraitCompiler} from '../../transform'; import {IncrementalCompilation} from '../src/incremental'; runInEachFileSystem(() => { @@ -20,13 +21,14 @@ runInEachFileSystem(() => { {name: FOO_PATH, contents: `export const FOO = true;`}, ]); const fooSf = getSourceFileOrError(program, FOO_PATH); + const traitCompiler = {getAnalyzedRecords: () => new Map()} as TraitCompiler; const versionMapFirst = new Map([[FOO_PATH, 'version.1']]); const firstCompilation = IncrementalCompilation.fresh( program, versionMapFirst, ); - firstCompilation.recordSuccessfulAnalysis(null!); + firstCompilation.recordSuccessfulAnalysis(traitCompiler); firstCompilation.recordSuccessfulEmit(fooSf); const versionMapSecond = new Map([[FOO_PATH, 'version.2']]); @@ -34,7 +36,7 @@ runInEachFileSystem(() => { program, versionMapSecond, program, firstCompilation.state, new Set(), NOOP_PERF_RECORDER); - secondCompilation.recordSuccessfulAnalysis(null!); + secondCompilation.recordSuccessfulAnalysis(traitCompiler); expect(secondCompilation.safeToSkipEmit(fooSf)).toBeFalse(); }); }); diff --git a/packages/compiler-cli/src/ngtsc/transform/src/compilation.ts b/packages/compiler-cli/src/ngtsc/transform/src/compilation.ts index 6c8ba0da9c..a189f5d4a9 100644 --- a/packages/compiler-cli/src/ngtsc/transform/src/compilation.ts +++ b/packages/compiler-cli/src/ngtsc/transform/src/compilation.ts @@ -166,6 +166,18 @@ export class TraitCompiler implements ProgramTypeCheckAdapter { return records; } + getAnalyzedRecords(): Map { + const result = new Map(); + for (const [sf, classes] of this.fileToClasses) { + const records: ClassRecord[] = []; + for (const clazz of classes) { + records.push(this.classes.get(clazz)!); + } + result.set(sf, records); + } + return result; + } + /** * Import a `ClassRecord` from a previous compilation. *