@@ -13,6 +13,8 @@ import {
13
13
PropertyWrite ,
14
14
TmplAstBoundAttribute ,
15
15
TmplAstBoundEvent ,
16
+ TmplAstComponent ,
17
+ TmplAstDirective ,
16
18
TmplAstElement ,
17
19
TmplAstForLoopBlock ,
18
20
TmplAstForLoopBlockEmpty ,
@@ -23,6 +25,7 @@ import {
23
25
TmplAstReference ,
24
26
TmplAstSwitchBlockCase ,
25
27
TmplAstTemplate ,
28
+ TmplAstTextAttribute ,
26
29
TmplAstVariable ,
27
30
TmplAstViewportDeferredTrigger ,
28
31
} from '@angular/compiler' ;
@@ -125,7 +128,7 @@ export interface OutOfBandDiagnosticRecorder {
125
128
/** Reports required inputs that haven't been bound. */
126
129
missingRequiredInputs (
127
130
id : TypeCheckId ,
128
- element : TmplAstElement | TmplAstTemplate ,
131
+ element : TmplAstElement | TmplAstTemplate | TmplAstComponent | TmplAstDirective ,
129
132
directiveName : string ,
130
133
isComponent : boolean ,
131
134
inputAliases : string [ ] ,
@@ -185,6 +188,34 @@ export interface OutOfBandDiagnosticRecorder {
185
188
* @param current the `TmplAstLetDeclaration` which is invalid.
186
189
*/
187
190
conflictingDeclaration ( id : TypeCheckId , current : TmplAstLetDeclaration ) : void ;
191
+
192
+ /**
193
+ * Reports that a named template dependency (e.g. `<Missing/>`) is not available.
194
+ * @param id Type checking ID of the template in which the dependency is declared.
195
+ * @param node Node that declares the dependency.
196
+ */
197
+ missingNamedTemplateDependency ( id : TypeCheckId , node : TmplAstComponent | TmplAstDirective ) : void ;
198
+
199
+ /**
200
+ * Reports that a templace dependency of the wrong kind has been referenced at a specific position
201
+ * (e.g. `<SomeDirective/>`).
202
+ * @param id Type checking ID of the template in which the dependency is declared.
203
+ * @param node Node that declares the dependency.
204
+ */
205
+ incorrectTemplateDependencyType ( id : TypeCheckId , node : TmplAstComponent | TmplAstDirective ) : void ;
206
+
207
+ /**
208
+ * Reports a binding inside directive syntax that does not match any of the inputs/outputs of
209
+ * the directive.
210
+ * @param id Type checking ID of the template in which the directive was defined.
211
+ * @param directive Directive that contains the binding.
212
+ * @param node Node declaring the binding.
213
+ */
214
+ unclaimedDirectiveBinding (
215
+ id : TypeCheckId ,
216
+ directive : TmplAstDirective ,
217
+ node : TmplAstBoundAttribute | TmplAstTextAttribute | TmplAstBoundEvent ,
218
+ ) : void ;
188
219
}
189
220
190
221
export class OutOfBandDiagnosticRecorderImpl implements OutOfBandDiagnosticRecorder {
@@ -467,7 +498,7 @@ export class OutOfBandDiagnosticRecorderImpl implements OutOfBandDiagnosticRecor
467
498
468
499
missingRequiredInputs (
469
500
id : TypeCheckId ,
470
- element : TmplAstElement | TmplAstTemplate ,
501
+ element : TmplAstElement | TmplAstTemplate | TmplAstComponent | TmplAstDirective ,
471
502
directiveName : string ,
472
503
isComponent : boolean ,
473
504
inputAliases : string [ ] ,
@@ -656,6 +687,58 @@ export class OutOfBandDiagnosticRecorderImpl implements OutOfBandDiagnosticRecor
656
687
) ,
657
688
) ;
658
689
}
690
+
691
+ missingNamedTemplateDependency ( id : TypeCheckId , node : TmplAstComponent | TmplAstDirective ) : void {
692
+ this . _diagnostics . push (
693
+ makeTemplateDiagnostic (
694
+ id ,
695
+ this . resolver . getTemplateSourceMapping ( id ) ,
696
+ node . startSourceSpan ,
697
+ ts . DiagnosticCategory . Error ,
698
+ ngErrorCode ( ErrorCode . MISSING_NAMED_TEMPLATE_DEPENDENCY ) ,
699
+ // Wording is meant to mimic the wording TS uses in their diagnostic for missing symbols.
700
+ `Cannot find name "${ node instanceof TmplAstDirective ? node . name : node . componentName } ".` ,
701
+ ) ,
702
+ ) ;
703
+ }
704
+
705
+ incorrectTemplateDependencyType (
706
+ id : TypeCheckId ,
707
+ node : TmplAstComponent | TmplAstDirective ,
708
+ ) : void {
709
+ this . _diagnostics . push (
710
+ makeTemplateDiagnostic (
711
+ id ,
712
+ this . resolver . getTemplateSourceMapping ( id ) ,
713
+ node . startSourceSpan ,
714
+ ts . DiagnosticCategory . Error ,
715
+ ngErrorCode ( ErrorCode . INCORRECT_NAMED_TEMPLATE_DEPENDENCY_TYPE ) ,
716
+ `Incorrect reference type. Type must be an ${ node instanceof TmplAstComponent ? '@Component' : '@Directive' } .` ,
717
+ ) ,
718
+ ) ;
719
+ }
720
+
721
+ unclaimedDirectiveBinding (
722
+ id : TypeCheckId ,
723
+ directive : TmplAstDirective ,
724
+ node : TmplAstBoundAttribute | TmplAstTextAttribute | TmplAstBoundEvent ,
725
+ ) : void {
726
+ const errorMsg =
727
+ `Directive ${ directive . name } does not have an ` +
728
+ `${ node instanceof TmplAstBoundEvent ? 'output' : 'input' } named "${ node . name } ". ` +
729
+ `Bindings to directives must target existing inputs or outputs.` ;
730
+
731
+ this . _diagnostics . push (
732
+ makeTemplateDiagnostic (
733
+ id ,
734
+ this . resolver . getTemplateSourceMapping ( id ) ,
735
+ node . keySpan || node . sourceSpan ,
736
+ ts . DiagnosticCategory . Error ,
737
+ ngErrorCode ( ErrorCode . UNCLAIMED_DIRECTIVE_BINDING ) ,
738
+ errorMsg ,
739
+ ) ,
740
+ ) ;
741
+ }
659
742
}
660
743
661
744
function makeInlineDiagnostic (
0 commit comments