New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(compiler-cli): implement more host directive validations as diagnostics #47768
fix(compiler-cli): implement more host directive validations as diagnostics #47768
Conversation
@@ -357,8 +357,8 @@ runInEachFileSystem(() => { | |||
import {ɵɵDirectiveDeclaration} from '@angular/core'; | |||
|
|||
export declare class ExternalDir { | |||
static ɵdir: ɵɵDirectiveDeclaration<ExternalDir, '[test]', never, never, | |||
{input: "input"}, {output: "output"}, never, true, never>; | |||
static ɵdir: ɵɵDirectiveDeclaration<ExternalDir, '[test]', never, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fixing something I messed up when I first wrote the test. The new diagnostics picked up on it.
@@ -434,7 +434,7 @@ runInEachFileSystem(() => { | |||
diag.messageText.messageText; | |||
} | |||
|
|||
it('should throw if a host directive is not standalone', () => { | |||
it('should produce a diagnostic if a host directive is not standalone', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I renamed all these tests talking about "throwing an error" to be more accurate.
*/ | ||
function validateMappings( | ||
bindingType: 'input'|'output', def: DirectiveDef<unknown>, | ||
hostDirectiveDefs: HostDirectiveBindingMap) { | ||
hostDirectiveBindings: HostDirectiveBindingMap) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This just renames the parameter to be more accurate.
@@ -3072,52 +3072,6 @@ suppress | |||
`Argument of type 'string' is not assignable to parameter of type 'number'.` | |||
]); | |||
}); | |||
|
|||
it('should check bindings to host directive inputs referring to the private name when there is a different public name', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test isn't valid anymore since it was testing what happens when trying to alias to the private name of an input/output.
…ostics Implements more of the runtime validations for host directives as compiler diagnostics so that they can be caught earlier. Also does some minor cleanup.
b076d7a
to
fc73369
Compare
bindingType: 'input'|'output', hostDirectiveMeta: HostDirectiveMeta, meta: DirectiveMeta, | ||
origin: ts.Expression, diagnostics: ts.DiagnosticWithLocation[]) { | ||
const className = meta.name; | ||
const hostDirectiveMappings = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why you don't explicitly declare the type, for ease of reading the code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because TS can infer the type and the reader can hover over the name for more information.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
reviewed-for: public-api, fw-core
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed-for: public-api
Caretaker note: this PR was forced green for g3, because the only two failing targets were flakes. The g3 check status above doesn't reflect it, because we're in a transition period between two different ways of reporting the g3 status. |
This PR was merged into the repository by commit f97bebf. |
…ostics (angular#47768) Implements more of the runtime validations for host directives as compiler diagnostics so that they can be caught earlier. Also does some minor cleanup. PR Close angular#47768
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Implements more of the runtime validations for host directives as compiler diagnostics so that they can be caught earlier. Also does some minor cleanup.