use of com.google.javascript.rhino.Node.TypeDeclarationNode in project closure-compiler by google.
the class TypeSyntaxTest method testArrayType.
public void testArrayType() {
TypeDeclarationNode arrayOfString = arrayType(stringType());
assertVarType("string[]", arrayOfString, "var foo: string[];");
parse("var foo: string[][];");
}
use of com.google.javascript.rhino.Node.TypeDeclarationNode in project closure-compiler by google.
the class TypeSyntaxTest method testUnionType.
public void testUnionType() {
parse("var x: string | number[];");
parse("var x: number[] | string;");
parse("var x: Array<Foo> | number[];");
parse("var x: (string | number)[];");
Node ast = parse("var x: string | number[] | Array<Foo>;");
TypeDeclarationNode union = (TypeDeclarationNode) (ast.getFirstFirstChild().getProp(Node.DECLARED_TYPE_EXPR));
assertEquals(3, union.getChildCount());
}
use of com.google.javascript.rhino.Node.TypeDeclarationNode in project closure-compiler by google.
the class TypeSyntaxTest method testParameterizedType.
public void testParameterizedType() {
TypeDeclarationNode parameterizedType = parameterizedType(namedType("my.parameterized.Type"), ImmutableList.of(namedType("ns.A"), namedType("ns.B")));
assertVarType("parameterized type 2 args", parameterizedType, "var x: my.parameterized.Type<ns.A, ns.B>;");
parse("var x: Foo<Bar<Baz>>;");
parse("var x: A<B<C<D>>>;");
}
Aggregations