Skip to content

Commit

Permalink
fix: support Vega-Lite again
Browse files Browse the repository at this point in the history
  • Loading branch information
domoritz committed Oct 10, 2020
1 parent 4e04a72 commit 80589d6
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/NodeParser/CallExpressionParser.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { TupleType } from "./../Type/TupleType";
import ts from "typescript";
import { Context, NodeParser } from "../NodeParser";
import { SubNodeParser } from "../SubNodeParser";
import { BaseType } from "../Type/BaseType";
import { UnionType } from "../Type/UnionType";
import { LiteralType } from "../Type/LiteralType";

export class CallExpressionParser implements SubNodeParser {
public constructor(private typeChecker: ts.TypeChecker, private childNodeParser: NodeParser) {}
Expand All @@ -11,6 +14,14 @@ export class CallExpressionParser implements SubNodeParser {
}
public createType(node: ts.CallExpression, context: Context): BaseType {
const type = this.typeChecker.getTypeAtLocation(node);

// FIXME: remove special case
if ("typeArguments" in type) {
return new TupleType([
new UnionType((type as any).typeArguments[0].types.map((t: any) => new LiteralType(t.value))),
]);
}

const symbol = type.symbol || type.aliasSymbol;
const decl = symbol.valueDeclaration || symbol.declarations[0];
const subContext = this.createSubContext(node, context);
Expand Down

0 comments on commit 80589d6

Please sign in to comment.