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
1 change: 1 addition & 0 deletions goldens/public-api/compiler-cli/error_code.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export enum ErrorCode {
CONFIG_FLAT_MODULE_NO_INDEX = 4001,
// (undocumented)
CONFIG_STRICT_TEMPLATES_IMPLIES_FULL_TEMPLATE_TYPECHECK = 4002,
CONFLICTING_HOST_DIRECTIVE_BINDING = 8024,
CONFLICTING_INPUT_TRANSFORM = 2020,
CONFLICTING_LET_DECLARATION = 8017,
CONTROL_FLOW_PREVENTING_CONTENT_PROJECTION = 8011,
Expand Down
1 change: 0 additions & 1 deletion packages/compiler-cli/private/hybrid_analysis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ 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 {ClassPropertyMapping} from '../src/ngtsc/metadata/src/property_mapping';
export type {TypeCheckSourceResolver} from '../src/ngtsc/typecheck/src/tcb_util';
export {
createHostElement,
Expand Down
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 {ClassPropertyName} from '@angular/compiler';
import ts from 'typescript';

import {
Expand All @@ -16,7 +17,6 @@ import {
} from '../../../diagnostics';
import {Reference} from '../../../imports';
import {
ClassPropertyName,
DirectiveMeta,
flattenInheritedDirectiveMetadata,
HostDirectiveMeta,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
* found in the LICENSE file at https://angular.dev/license
*/

import {outputAst} from '@angular/compiler';
import {ClassPropertyMapping, outputAst} from '@angular/compiler';

import {ClassPropertyMapping, InputMapping} from '../../../metadata';
import {InputMapping} from '../../../metadata';
import {CompileResult} from '../../../transform';

/** Generates additional fields to be added to a class that has inputs with transform functions. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import {
ViewEncapsulation,
DirectiveMatcher,
SelectorlessMatcher,
MatchSource,
} from '@angular/compiler';
import ts from 'typescript';

Expand Down Expand Up @@ -73,7 +74,6 @@ import {
DirectiveMeta,
extractDirectiveTypeCheckMeta,
HostDirectivesResolver,
MatchSource,
MetadataReader,
MetadataRegistry,
MetaKind,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ import {
R3TemplateDependencyMetadata,
SchemaMetadata,
TmplAstDeferredBlock,
ClassPropertyMapping,
} from '@angular/compiler';
import ts from 'typescript';

import {Reference} from '../../../imports';
import {
ClassPropertyMapping,
DirectiveResources,
DirectiveTypeCheckMeta,
HostDirectiveMeta,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
*/

import {
ClassPropertyMapping,
compileClassMetadata,
compileDeclareClassMetadata,
compileDeclareDirectiveFromMetadata,
compileDirectiveFromMetadata,
ConstantPool,
FactoryTarget,
makeBindingParser,
MatchSource,
R3ClassMetadata,
R3DirectiveMetadata,
R3TargetBinder,
Expand All @@ -27,13 +29,11 @@ import {
SemanticDepGraphUpdater,
} from '../../../incremental/semantic_graph';
import {
ClassPropertyMapping,
DirectiveResources,
DirectiveTypeCheckMeta,
extractDirectiveTypeCheckMeta,
HostDirectiveMeta,
InputMapping,
MatchSource,
MetadataReader,
MetadataRegistry,
MetaKind,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
* found in the LICENSE file at https://angular.dev/license
*/

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

import {ErrorCode, FatalDiagnosticError} from '../../../diagnostics';
import {ImportedSymbolsTracker} from '../../../imports';
import {InputOrOutput} from '../../../metadata';
import {ClassMember, ClassMemberAccessLevel, ReflectionHost} from '../../../reflection';

import {validateAccessOfInitializerApiMember} from './initializer_function_access';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import {
ArrowFunctionExpr,
WrappedNodeExpr,
literal,
ClassPropertyMapping,
InputOrOutput,
} from '@angular/compiler';
import ts from 'typescript';

Expand All @@ -42,11 +44,9 @@ import {
ReferenceEmitter,
} from '../../../imports';
import {
ClassPropertyMapping,
DecoratorInputTransform,
HostDirectiveMeta,
InputMapping,
InputOrOutput,
isHostDirectiveMetaForGlobalMode,
Resource,
} from '../../../metadata';
Expand Down
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 {ClassPropertyMapping, InputOrOutput} from '@angular/compiler';
import {
areTypeParametersEqual,
isArrayEqual,
Expand All @@ -14,13 +15,7 @@ import {
SemanticSymbol,
SemanticTypeParameter,
} from '../../../incremental/semantic_graph';
import {
ClassPropertyMapping,
DirectiveTypeCheckMeta,
InputMapping,
InputOrOutput,
TemplateGuardMeta,
} from '../../../metadata';
import {DirectiveTypeCheckMeta, InputMapping, TemplateGuardMeta} from '../../../metadata';
import {ClassDeclaration} from '../../../reflection';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
R3TargetBinder,
SelectorMatcher,
TmplAstElement,
MatchSource,
} from '@angular/compiler';
import ts from 'typescript';

Expand Down Expand Up @@ -127,6 +128,9 @@ runInEachFileSystem(() => {
const analysis = analyzeDirective(program, 'TestDir');
const matcher = new SelectorMatcher<T2DirectiveMeta[]>();
const dirMeta: T2DirectiveMeta = {
ref: {
key: 'TestDir',
},
exportAs: null,
inputs: analysis.inputs,
outputs: analysis.outputs,
Expand All @@ -137,6 +141,7 @@ runInEachFileSystem(() => {
animationTriggerNames: null,
ngContentSelectors: null,
preserveWhitespaces: false,
matchSource: MatchSource.Selector,
};
matcher.addSelectables(CssSelector.parse('[dir]'), [dirMeta]);

Expand Down
5 changes: 5 additions & 0 deletions packages/compiler-cli/src/ngtsc/diagnostics/src/error_code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,11 @@ export enum ErrorCode {
*/
MULTIPLE_MATCHING_COMPONENTS = 8023,

/**
* Raised when a host directive input/output is exposed multiple times under the same name.
*/
CONFLICTING_HOST_DIRECTIVE_BINDING = 8024,

/**
* A two way binding in a template has an incorrect syntax,
* parentheses outside brackets. For example:
Expand Down
10 changes: 2 additions & 8 deletions packages/compiler-cli/src/ngtsc/docs/src/class_extractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,11 @@
* found in the LICENSE file at https://angular.dev/license
*/

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

import {Reference} from '../../imports';
import {
DirectiveMeta,
InputMapping,
InputOrOutput,
MetadataReader,
NgModuleMeta,
PipeMeta,
} from '../../metadata';
import {DirectiveMeta, InputMapping, MetadataReader, PipeMeta} from '../../metadata';

import {
ClassEntry,
Expand Down
15 changes: 14 additions & 1 deletion packages/compiler-cli/src/ngtsc/imports/src/references.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {Expression} from '@angular/compiler';
import ts from 'typescript';

import {AmbientImport} from '../../reflection';
import {identifierOfNode} from '../../util/src/typescript';
import {getSourceFile, identifierOfNode} from '../../util/src/typescript';

export interface OwningModule {
specifier: string;
Expand Down Expand Up @@ -57,6 +57,8 @@ export class Reference<T extends ts.Node = ts.Node> {

readonly isAmbient: boolean;

readonly key: string;

constructor(
readonly node: T,
bestGuessOwningModule: OwningModule | AmbientImport | null = null,
Expand All @@ -70,9 +72,20 @@ export class Reference<T extends ts.Node = ts.Node> {
}

const id = identifierOfNode(node);
const sourceFile = getSourceFile(node);

if (id !== null) {
this.identifiers.push(id);
}

// The source file might not be defined for synthetic nodes.
if (sourceFile) {
this.key = `${sourceFile.fileName}#${node.getStart()}`;
} else {
// `getStart` will throw if there's no source file.
const position = id && id.getSourceFile() ? id.getStart() : null;
this.key = `${this.bestGuessOwningModule?.specifier}#${id?.text}#${position}`;
}
}

/**
Expand Down
4 changes: 3 additions & 1 deletion packages/compiler-cli/src/ngtsc/indexer/test/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@

import {
BoundTarget,
ClassPropertyMapping,
CssSelector,
DirectiveMatcher,
MatchSource,
parseTemplate,
ParseTemplateOptions,
R3TargetBinder,
Expand All @@ -20,7 +22,6 @@ import ts from 'typescript';

import {absoluteFrom, AbsoluteFsPath} from '../../file_system';
import {Reference} from '../../imports';
import {ClassPropertyMapping} from '../../metadata';
import {ClassDeclaration} from '../../reflection';
import {getDeclaration, makeProgram} from '../../testing';
import {ComponentMeta} from '../src/context';
Expand Down Expand Up @@ -69,6 +70,7 @@ export function getBoundTemplate(
animationTriggerNames: null,
ngContentSelectors: null,
preserveWhitespaces: false,
matchSource: MatchSource.Selector,
}));

let matcher: DirectiveMatcher<ComponentMeta>;
Expand Down
6 changes: 0 additions & 6 deletions packages/compiler-cli/src/ngtsc/metadata/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,5 @@ export {
CompoundMetadataReader,
isHostDirectiveMetaForGlobalMode,
} from './src/util';
export {
BindingPropertyName,
ClassPropertyMapping,
ClassPropertyName,
InputOrOutput,
} from './src/property_mapping';
export {ExportedProviderStatusResolver} from './src/providers';
export {HostDirectivesResolver} from './src/host_directives_resolver';
17 changes: 4 additions & 13 deletions packages/compiler-cli/src/ngtsc/metadata/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ import {
Expression,
SchemaMetadata,
ExternalReference,
MatchSource,
ClassPropertyName,
InputOrOutput,
ClassPropertyMapping,
} from '@angular/compiler';
import ts from 'typescript';

import {Reference} from '../../imports';
import {ClassDeclaration} from '../../reflection';

import {ClassPropertyMapping, ClassPropertyName, InputOrOutput} from './property_mapping';

/**
* Metadata collected for an `NgModule`.
*/
Expand Down Expand Up @@ -134,17 +136,6 @@ export enum MetaKind {
NgModule,
}

/**
* Possible ways that a directive can be matched.
*/
export enum MatchSource {
/** The directive was matched by its selector. */
Selector,

/** The directive was applied as a host directive. */
HostDirective,
}

/** Metadata for a single input mapping. */
export type InputMapping = InputOrOutput & {
required: boolean;
Expand Down
3 changes: 1 addition & 2 deletions packages/compiler-cli/src/ngtsc/metadata/src/dts.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 {ClassPropertyMapping, MatchSource} from '@angular/compiler';
import ts from 'typescript';

import {OwningModule, Reference} from '../../imports';
Expand All @@ -21,13 +22,11 @@ import {
DirectiveMeta,
HostDirectiveMeta,
InputMapping,
MatchSource,
MetadataReader,
MetaKind,
NgModuleMeta,
PipeMeta,
} from './api';
import {ClassPropertyMapping} from './property_mapping';
import {
extractDirectiveTypeCheckMeta,
extractReferencesFromType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
* found in the LICENSE file at https://angular.dev/license
*/

import {DirectiveMeta, InputMapping, MatchSource, MetadataReader} from '../../metadata/src/api';
import {ClassPropertyMapping, InputOrOutput, MatchSource} from '@angular/compiler';
import {DirectiveMeta, InputMapping, MetadataReader} from '../../metadata/src/api';
import {ClassDeclaration} from '../../reflection';
import {ClassPropertyMapping, InputOrOutput} from '../src/property_mapping';

import {flattenInheritedDirectiveMetadata} from './inheritance';
import {isHostDirectiveMetaForGlobalMode} from './util';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
* found in the LICENSE file at https://angular.dev/license
*/

import {ClassPropertyMapping, ClassPropertyName} from '@angular/compiler';
import {Reference} from '../../imports';
import {ClassDeclaration} from '../../reflection';

import {DirectiveMeta, HostDirectiveMeta, InputMapping, MetadataReader} from './api';
import {ClassPropertyMapping, ClassPropertyName} from './property_mapping';

/**
* Given a reference to a directive, return a flattened version of its `DirectiveMeta` metadata
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler-cli/src/ngtsc/metadata/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import {
PipeMeta,
TemplateGuardMeta,
} from './api';
import {ClassPropertyMapping, ClassPropertyName} from './property_mapping';
import {TypeEntityToDeclarationError} from '../../reflection/src/typescript';
import {ClassPropertyMapping, ClassPropertyName} from '@angular/compiler';

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