JS: Extractor handle error instead of exiting.#18984
Merged
Napalys merged 2 commits intogithub:mainfrom Mar 17, 2025
Merged
Conversation
5c50f61 to
3cdd34d
Compare
3cdd34d to
c3ecf70
Compare
Contributor
|
In @Override
public Integer visit(ParenthesizedExpression nd, Void c) {
return parenthesizedTypeExpr;
} |
09f41bc to
6d3761f
Compare
6d3761f to
1468e81
Compare
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR updates the extractor to handle errors gracefully by introducing validity checks in type expression conversions. Key changes include:
- Adding test files with invalid extends to trigger extractor error handling.
- Introducing a default method isValidExpression in ITypeExpression.
- Implementing an override of isValidExpression in MemberExpression.
- Modifying TypeScriptASTConverter to use isValidExpression in type conversion.
Reviewed Changes
Copilot reviewed 5 out of 7 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| javascript/extractor/tests/ts/input/invalidExtends.ts | Adds test cases with invalid "extends" constructs for extractor error handling |
| javascript/extractor/src/com/semmle/ts/ast/ITypeExpression.java | Adds default validity check method in the ITypeExpression interface |
| javascript/extractor/src/com/semmle/js/ast/MemberExpression.java | Adds an override for isValidExpression to check allowed object types |
| javascript/extractor/src/com/semmle/ts/extractor/TypeScriptASTConverter.java | Updates the asType method to apply the validity check from ITypeExpression |
Files not reviewed (2)
- javascript/ql/test/library-tests/TypeScript/Types/printAst.expected: Language not supported
- javascript/ql/test/library-tests/TypeScript/Types/tests.expected: Language not supported
Tip: Copilot only keeps its highest confidence comments to reduce noise and keep you focused. Learn more
asgerf
reviewed
Mar 14, 2025
javascript/extractor/src/com/semmle/js/ast/MemberExpression.java
Outdated
Show resolved
Hide resolved
javascript/extractor/src/com/semmle/js/ast/MemberExpression.java
Outdated
Show resolved
Hide resolved
…ll for type validation. Co-authored-by: Asgerf <asgerf@github.com>
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes extractor error discovered in #18899 (comment)