fix(compiler-cli): report errors when initializer APIs (input etc.) are used on private fields#54981
Closed
devversion wants to merge 6 commits intoangular:mainfrom
Closed
fix(compiler-cli): report errors when initializer APIs (input etc.) are used on private fields#54981devversion wants to merge 6 commits intoangular:mainfrom
input etc.) are used on private fields#54981devversion wants to merge 6 commits intoangular:mainfrom
Conversation
crisbeto
reviewed
Mar 21, 2024
packages/compiler-cli/src/ngtsc/annotations/directive/src/initializer_functions.ts
Outdated
Show resolved
Hide resolved
crisbeto
reviewed
Mar 21, 2024
packages/compiler-cli/src/ngtsc/annotations/directive/src/initializer_functions.ts
Outdated
Show resolved
Hide resolved
93aedbd to
98b1693
Compare
crisbeto
approved these changes
Mar 22, 2024
packages/compiler-cli/src/ngtsc/annotations/directive/src/initializer_function_access.ts
Outdated
Show resolved
Hide resolved
Member
Author
|
Note: This is a new error code for the compiler which shouldn't need public API approval |
Updates the function that parses initializer APIs to check any `Expression`, instead of expecting a class member. This will be useful for the upcoming changes.
…nd visibility This commit changes the TypeScript reflection host to: * inspect / process ES private fields. e.g. `#someField` — those are ignored right now and we would want to check them to issue diagnostics. * determine an access level of a class member. E.g. a member may be public, may be private, may be ES private, or public readonly. This can then be used in various checks later.
…r APIs An initializer API like `input`, `output`, or signal queries may not be compatible with certain access levels. E.g. queries cannot work with ES private class fields. This commit introduces a check for access levels into the initializer API recognition— enforcing that every initializer API *clearly* specifies what type of access is allowed.
…ivate fields This commit ensures that the new APIs like `input`, `model`, `output`, or signal-based queries are not accidentally used on fields that have a problematic visibility/access level that won't work. For example, queries defined using a private identifier (e.g. `#bla`) will not be accessible by the Angular runtime and therefore _dont_ work. This commit ensures: - `input` is only declared via public and protected fields. - `output` is only declared via public and protected fields. - `model` is only declared via public and protected fields. - signal queries are only declared via public, protected and TS private fields (`private` works, while `#bla` does not). Fixes angular#54863.
…nosticError` For `FatalDiagnosticError` we are currently hiding the `message` string field in favor of the actual TS `diagnosticMessage`. This works as expected, but makes these errors hard to debug in certain environments (e.g. Jasmine). That is because `null` is the value of `message` at runtime. We fix this by just overriding the type, like we originally intended to do. In addition, we properly render message chains in the `Error#message` field— so that these errors, when uncaught, are somewhat reasonable and can be useful.
…talDiagnosticError` Address feedback
d39c6b1 to
9c4a030
Compare
Contributor
|
This PR was merged into the repository by commit 03b1ac3. |
dylhunn
pushed a commit
that referenced
this pull request
Mar 27, 2024
…nd visibility (#54981) This commit changes the TypeScript reflection host to: * inspect / process ES private fields. e.g. `#someField` — those are ignored right now and we would want to check them to issue diagnostics. * determine an access level of a class member. E.g. a member may be public, may be private, may be ES private, or public readonly. This can then be used in various checks later. PR Close #54981
dylhunn
pushed a commit
that referenced
this pull request
Mar 27, 2024
…r APIs (#54981) An initializer API like `input`, `output`, or signal queries may not be compatible with certain access levels. E.g. queries cannot work with ES private class fields. This commit introduces a check for access levels into the initializer API recognition— enforcing that every initializer API *clearly* specifies what type of access is allowed. PR Close #54981
dylhunn
pushed a commit
that referenced
this pull request
Mar 27, 2024
…ivate fields (#54981) This commit ensures that the new APIs like `input`, `model`, `output`, or signal-based queries are not accidentally used on fields that have a problematic visibility/access level that won't work. For example, queries defined using a private identifier (e.g. `#bla`) will not be accessible by the Angular runtime and therefore _dont_ work. This commit ensures: - `input` is only declared via public and protected fields. - `output` is only declared via public and protected fields. - `model` is only declared via public and protected fields. - signal queries are only declared via public, protected and TS private fields (`private` works, while `#bla` does not). Fixes #54863. PR Close #54981
dylhunn
pushed a commit
that referenced
this pull request
Mar 27, 2024
…nosticError` (#54981) For `FatalDiagnosticError` we are currently hiding the `message` string field in favor of the actual TS `diagnosticMessage`. This works as expected, but makes these errors hard to debug in certain environments (e.g. Jasmine). That is because `null` is the value of `message` at runtime. We fix this by just overriding the type, like we originally intended to do. In addition, we properly render message chains in the `Error#message` field— so that these errors, when uncaught, are somewhat reasonable and can be useful. PR Close #54981
|
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See individual commits