refactor(compiler-cli): update type checker symbols to include more information (#38844)
This commit updates the symbols in the TemplateTypeCheck API and methods for retrieving them: * Include `isComponent` and `selector` for directives so callers can determine which attributes on an element map to the matched directives. * Add a new `TextAttributeSymbol` and return this when requesting a symbol for a `TextAttribute`. * When requesting a symbol for `PropertyWrite` and `MethodCall`, use the `nameSpan` to retrieve symbols. * Add fix to retrieve generic directives attached to elements/templates. PR Close #38844
This commit is contained in:

committed by
Alex Rickabaugh

parent
494a2f3be4
commit
c74917a7d5
@ -38,6 +38,7 @@ function makeSelectorMatcher(): SelectorMatcher<DirectiveMeta> {
|
||||
inputs: new IdentityInputMapping(['ngForOf']),
|
||||
outputs: new IdentityInputMapping([]),
|
||||
isComponent: false,
|
||||
selector: '[ngFor][ngForOf]',
|
||||
});
|
||||
matcher.addSelectables(CssSelector.parse('[dir]'), {
|
||||
name: 'Dir',
|
||||
@ -45,6 +46,7 @@ function makeSelectorMatcher(): SelectorMatcher<DirectiveMeta> {
|
||||
inputs: new IdentityInputMapping([]),
|
||||
outputs: new IdentityInputMapping([]),
|
||||
isComponent: false,
|
||||
selector: '[dir]'
|
||||
});
|
||||
matcher.addSelectables(CssSelector.parse('[hasOutput]'), {
|
||||
name: 'HasOutput',
|
||||
@ -52,6 +54,7 @@ function makeSelectorMatcher(): SelectorMatcher<DirectiveMeta> {
|
||||
inputs: new IdentityInputMapping([]),
|
||||
outputs: new IdentityInputMapping(['outputBinding']),
|
||||
isComponent: false,
|
||||
selector: '[hasOutput]'
|
||||
});
|
||||
matcher.addSelectables(CssSelector.parse('[hasInput]'), {
|
||||
name: 'HasInput',
|
||||
@ -59,6 +62,7 @@ function makeSelectorMatcher(): SelectorMatcher<DirectiveMeta> {
|
||||
inputs: new IdentityInputMapping(['inputBinding']),
|
||||
outputs: new IdentityInputMapping([]),
|
||||
isComponent: false,
|
||||
selector: '[hasInput]'
|
||||
});
|
||||
return matcher;
|
||||
}
|
||||
@ -103,6 +107,7 @@ describe('t2 binding', () => {
|
||||
inputs: new IdentityInputMapping([]),
|
||||
outputs: new IdentityInputMapping([]),
|
||||
isComponent: false,
|
||||
selector: 'text[dir]'
|
||||
});
|
||||
const binder = new R3TargetBinder(matcher);
|
||||
const res = binder.bind({template: template.nodes});
|
||||
|
Reference in New Issue
Block a user