
Previously in the template type-checking engine, it was assumed that every input file would have an associated type-checking shim. The type check block code for all components in the input file would be generated into this shim. This is fine for whole-program type checking operations, but to support the language service's requirements for low latency, it would be ideal to be able to check a single component in isolation, especially if the component is declared along with many others in a single file. This commit removes the assumption that the file/shim mapping is 1:1, and introduces the concept of component-to-shim mapping. Any `TypeCheckingProgramStrategy` must provide such a mapping. To achieve this: * type checking record information is now split into file-level data as well as per-shim data. * components are now assigned a stable `TemplateId` which is unique to the file in which they're declared. PR Close #38105
62 lines
2.1 KiB
TypeScript
62 lines
2.1 KiB
TypeScript
/**
|
|
* @license
|
|
* Copyright Google LLC All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.io/license
|
|
*/
|
|
|
|
import * as ts from 'typescript';
|
|
import {AbsoluteFsPath} from '../file_system';
|
|
|
|
/**
|
|
* Interface of the incremental build engine.
|
|
*
|
|
* `AnalysisT` is a generic type representing a unit of work. This is generic to avoid a cyclic
|
|
* dependency between the incremental engine API definition and its consumer(s).
|
|
* `FileTypeCheckDataT` is a generic type representing template type-checking data for a particular
|
|
* input file, which is generic for the same reason.
|
|
*/
|
|
export interface IncrementalBuild<AnalysisT, FileTypeCheckDataT> {
|
|
/**
|
|
* Retrieve the prior analysis work, if any, done for the given source file.
|
|
*/
|
|
priorWorkFor(sf: ts.SourceFile): AnalysisT[]|null;
|
|
|
|
/**
|
|
* Retrieve the prior type-checking work, if any, that's been done for the given source file.
|
|
*/
|
|
priorTypeCheckingResultsFor(fileSf: ts.SourceFile): FileTypeCheckDataT|null;
|
|
}
|
|
|
|
/**
|
|
* Tracks dependencies between source files or resources in the application.
|
|
*/
|
|
export interface DependencyTracker<T extends {fileName: string} = ts.SourceFile> {
|
|
/**
|
|
* Record that the file `from` depends on the file `on`.
|
|
*/
|
|
addDependency(from: T, on: T): void;
|
|
|
|
/**
|
|
* Record that the file `from` depends on the resource file `on`.
|
|
*/
|
|
addResourceDependency(from: T, on: AbsoluteFsPath): void;
|
|
|
|
/**
|
|
* Record that the file `from` depends on the file `on` as well as `on`'s direct dependencies.
|
|
*
|
|
* This operation is reified immediately, so if future dependencies are added to `on` they will
|
|
* not automatically be added to `from`.
|
|
*/
|
|
addTransitiveDependency(from: T, on: T): void;
|
|
|
|
/**
|
|
* Record that the file `from` depends on the resource dependencies of `resourcesOf`.
|
|
*
|
|
* This operation is reified immediately, so if future resource dependencies are added to
|
|
* `resourcesOf` they will not automatically be added to `from`.
|
|
*/
|
|
addTransitiveResources(from: T, resourcesOf: T): void;
|
|
}
|