Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,9 @@ public int getSymbol() {
public void setSymbol(int symbol) {
this.symbol = symbol;
}

@Override
public boolean isValidTypeExpression() {
return object instanceof ITypeExpression && ((ITypeExpression)object).isValidTypeExpression() || object instanceof DynamicImport;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@
* however, some expressions such as {@link Literal} type may occur in a type annotation because the
* TypeScript AST does not distinguish <code>null</code> literals from the <code>null</code> type.
*/
public interface ITypeExpression extends INode, ITypedAstNode {}
public interface ITypeExpression extends INode, ITypedAstNode {
public default boolean isValidTypeExpression() { return true; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -1907,7 +1907,7 @@ private Node convertOptionalType(JsonObject node, SourceLocation loc) throws Par
}

private ITypeExpression asType(Node node) {
return node instanceof ITypeExpression ? (ITypeExpression) node : null;
return node instanceof ITypeExpression && ((ITypeExpression)node).isValidTypeExpression() ? (ITypeExpression) node : null;
}

private List<ITypeExpression> convertChildrenAsTypes(JsonObject node, String child)
Expand Down
6 changes: 6 additions & 0 deletions javascript/extractor/tests/ts/input/invalidExtends.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
interface Invalid extends (foo.bar) {}
interface Invalid extends (foo).bar {}
interface Invalid extends foo[bar] {}
interface Invalid extends foo?.bar {}
interface Invalid extends foo!.bar {}
interface Invalid extends foo() {}
Loading