Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
refactor(compiler): move TCB generation logic into compiler
Moves the logic for generating type check blocks into the compiler since it isn't coupled to TypeScript anymore.

Note: the tests haven't been moved over, because they depend on the environment that's currently in `compiler-cli` and it still has some dependencies on TypeScript.
  • Loading branch information
crisbeto committed Apr 13, 2026
commit 454528caf4b1c2e03f893927b606301cad8281c5
21 changes: 0 additions & 21 deletions packages/compiler-cli/private/hybrid_analysis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,18 @@
* found in the LICENSE file at https://angular.dev/license
*/

// TCB generation exports for ng-hybrid-preprocessor
export {generateTypeCheckBlock} from '../src/ngtsc/typecheck/src/type_check_block';
export {
type TypeCheckingConfig,
type TcbComponentMetadata,
type TcbTypeCheckBlockMetadata,
type TcbTypeParameter,
type TypeCheckId,
type TcbDirectiveMetadata,
type TemplateDiagnostic,
type TcbReferenceMetadata,
type SourceMapping,
type OutOfBandDiagnosticRecorder,
type DomSchemaChecker,
type SymbolReference,
OutOfBandDiagnosticCategory,
SymbolKind,
} from '../src/ngtsc/typecheck/api';
export {RegistryDomSchemaChecker} from '../src/ngtsc/typecheck/src/dom';
export {Environment} from '../src/ngtsc/typecheck/src/environment';
export {TcbGenericContextBehavior} from '../src/ngtsc/typecheck/src/ops/context';
export {ImportManager} from '../src/ngtsc/translator';
export type {ReferenceEmitter} from '../src/ngtsc/imports';
export type {ReflectionHost, ClassDeclaration} from '../src/ngtsc/reflection';
export type {TypeCheckSourceResolver} from '../src/ngtsc/typecheck/src/tcb_util';
export {
createHostElement,
type SourceNode,
type StaticSourceNode,
type HostObjectLiteralBinding,
type HostListenerDecorator,
type HostBindingDecorator,
} from '../src/ngtsc/typecheck/src/host_bindings';
export {
findFirstMatchingNode,
ExpressionIdentifier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
R3DirectiveDependencyMetadata,
R3NgModuleDependencyMetadata,
R3PipeDependencyMetadata,
createHostElement,
R3TargetBinder,
R3TemplateDependency,
R3TemplateDependencyKind,
Expand All @@ -43,6 +44,7 @@ import {
DirectiveMatcher,
SelectorlessMatcher,
MatchSource,
TypeCheckId,
} from '@angular/compiler';
import ts from 'typescript';

Expand Down Expand Up @@ -96,12 +98,9 @@ import {
import {
ComponentScopeKind,
ComponentScopeReader,
DtsModuleScopeResolver,
LocalModuleScope,
LocalModuleScopeRegistry,
makeNotStandaloneDiagnostic,
makeUnknownComponentImportDiagnostic,
StandaloneScope,
TypeCheckScopeRegistry,
} from '../../../scope';
import {
Expand All @@ -118,7 +117,6 @@ import {
ResolveResult,
} from '../../../transform';
import {
TypeCheckId,
TypeCheckableDirectiveMeta,
TypeCheckContext,
TemplateContext,
Expand Down Expand Up @@ -193,7 +191,7 @@ import {
collectLegacyAnimationNames,
validateAndFlattenComponentImports,
} from './util';
import {getTemplateDiagnostics, createHostElement} from '../../../typecheck';
import {getTemplateDiagnostics} from '../../../typecheck';
import {JitDeclarationRegistry} from '../../common/src/jit_declaration_registry';
import {extractHmrMetatadata, getHmrUpdateDeclaration} from '../../../hmr';
import {getProjectRelativePath} from '../../../util/src/path';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
R3DirectiveMetadata,
R3TargetBinder,
WrappedNodeExpr,
createHostElement,
} from '@angular/compiler';
import ts from 'typescript';

Expand Down Expand Up @@ -92,7 +93,6 @@ import {
TypeCheckableDirectiveMeta,
TypeCheckContext,
} from '../../../typecheck/api';
import {createHostElement} from '../../../typecheck';

const FIELD_DECORATORS = [
'Input',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ import {
literal,
ClassPropertyMapping,
InputOrOutput,
HostObjectLiteralBinding,
HostListenerDecorator,
HostBindingDecorator,
SourceNode,
} from '@angular/compiler';
import ts from 'typescript';

Expand Down Expand Up @@ -92,13 +96,6 @@ import {tryParseSignalInputMapping} from './input_function';
import {tryParseSignalModelMapping} from './model_function';
import {tryParseInitializerBasedOutput} from './output_function';
import {tryParseSignalQueryFromInitializer} from './query_functions';
import {
HostObjectLiteralBinding,
HostListenerDecorator,
HostBindingDecorator,
SourceNode,
StaticSourceNode,
} from '../../../typecheck/src/host_bindings';

const EMPTY_OBJECT: {[key: string]: string} = {};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.dev/license
*/

import {ClassPropertyMapping, InputOrOutput} from '@angular/compiler';
import {ClassPropertyMapping, InputOrOutput, TemplateGuardMeta} from '@angular/compiler';
import {
areTypeParametersEqual,
isArrayEqual,
Expand All @@ -15,7 +15,7 @@ import {
SemanticSymbol,
SemanticTypeParameter,
} from '../../../incremental/semantic_graph';
import {DirectiveTypeCheckMeta, InputMapping, TemplateGuardMeta} from '../../../metadata';
import {DirectiveTypeCheckMeta, InputMapping} from '../../../metadata';
import {ClassDeclaration} from '../../../reflection';

/**
Expand Down
3 changes: 2 additions & 1 deletion packages/compiler-cli/src/ngtsc/core/src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* found in the LICENSE file at https://angular.dev/license
*/

import {TypeCheckingConfig} from '@angular/compiler';
import ts from 'typescript';

import {
Expand Down Expand Up @@ -109,7 +110,7 @@ import {
TraitCompiler,
} from '../../transform';
import {TemplateTypeCheckerImpl} from '../../typecheck';
import {OptimizeFor, TemplateTypeChecker, TypeCheckingConfig} from '../../typecheck/api';
import {OptimizeFor, TemplateTypeChecker} from '../../typecheck/api';
import {
ALL_DIAGNOSTIC_FACTORIES,
ExtendedTemplateCheckerImpl,
Expand Down
20 changes: 1 addition & 19 deletions packages/compiler-cli/src/ngtsc/metadata/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
ClassPropertyName,
InputOrOutput,
ClassPropertyMapping,
TemplateGuardMeta,
} from '@angular/compiler';
import ts from 'typescript';

Expand Down Expand Up @@ -332,25 +333,6 @@ export interface HostDirectiveMetaForLocalMode extends HostDirectiveMeta {
directive: Expression;
}

/**
* Metadata that describes a template guard for one of the directive's inputs.
*/
export interface TemplateGuardMeta {
/**
* The input name that this guard should be applied to.
*/
inputName: string;

/**
* Represents the type of the template guard.
*
* - 'invocation' means that a call to the template guard function is emitted so that its return
* type can result in narrowing of the input type.
* - 'binding' means that the input binding expression itself is used as template guard.
*/
type: 'invocation' | 'binding';
}

/**
* Metadata for a pipe within an NgModule's scope.
*/
Expand Down
3 changes: 1 addition & 2 deletions packages/compiler-cli/src/ngtsc/metadata/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ import {
MetadataReader,
NgModuleMeta,
PipeMeta,
TemplateGuardMeta,
} from './api';
import {TypeEntityToDeclarationError} from '../../reflection/src/typescript';
import {ClassPropertyMapping, ClassPropertyName} from '@angular/compiler';
import {ClassPropertyMapping, ClassPropertyName, TemplateGuardMeta} from '@angular/compiler';

export function extractReferencesFromType(
checker: ts.TypeChecker,
Expand Down
Loading
Loading