TS: Support readonly type expressions

This commit is contained in:
Asger F
2019-04-10 12:26:46 +01:00
parent 11f460c6a3
commit d5ae69d40a
7 changed files with 30 additions and 2 deletions

View File

@@ -66,6 +66,7 @@ public class TypeExprKinds {
private static final int optionalTypeExpr = 33;
private static final int restTypeExpr = 34;
private static final int bigintLiteralTypeExpr = 35;
private static final int readonlyTypeExpr = 36;
public static int getTypeExprKind(final INode type, final IdContext idcontext) {
Integer kind =
@@ -127,7 +128,11 @@ public class TypeExprKinds {
@Override
public Integer visit(UnaryTypeExpr nd, Void c) {
return keyofTypeExpr;
switch (nd.getKind()) {
case Keyof: return keyofTypeExpr;
case Readonly: return readonlyTypeExpr;
}
throw new CatastrophicError("Unhandled UnaryTypeExpr kind: " + nd.getKind());
}
@Override

View File

@@ -2132,6 +2132,9 @@ public class TypeScriptASTConverter {
if (operator.equals("KeyOfKeyword")) {
return new UnaryTypeExpr(loc, UnaryTypeExpr.Kind.Keyof, convertChildAsType(node, "type"));
}
if (operator.equals("ReadonlyKeyword")) {
return new UnaryTypeExpr(loc, UnaryTypeExpr.Kind.Readonly, convertChildAsType(node, "type"));
}
if (operator.equals("UniqueKeyword")) {
return new KeywordTypeExpr(loc, "unique symbol");
}