Node processTypeQuery(TypeQueryTree tree) { Iterator<String> segmentsIt = tree.segments.iterator(); Node node = newStringNode(Token.NAME, segmentsIt.next()); while (segmentsIt.hasNext()) { node = IR.getprop(node, IR.string(segmentsIt.next())); } return cloneProps(new TypeDeclarationNode(Token.TYPEOF, node)); }
Node processTypeQuery(TypeQueryTree tree) { Iterator<String> segmentsIt = tree.segments.iterator(); Node node = newStringNode(Token.NAME, segmentsIt.next()); while (segmentsIt.hasNext()) { node = IR.getprop(node, IR.string(segmentsIt.next())); } return cloneProps(new TypeDeclarationNode(Token.TYPEOF, node)); }
Node processRecordType(RecordTypeTree tree) { TypeDeclarationNode node = new TypeDeclarationNode(Token.RECORD_TYPE); for (ParseTree child : tree.members) { node.addChildToBack(transform(child)); } return cloneProps(node); }
@Override public TypeDeclarationNode cloneNode(boolean cloneTypeExprs) { return copyNodeFields(new TypeDeclarationNode(type, str), cloneTypeExprs); } }
private void maybeProcessType(Node typeTarget, ParseTree typeTree) { if (typeTree != null) { recordJsDoc(typeTree.location, typeTarget.getJSDocInfo()); Node typeExpression = convertTypeTree(typeTree); if (typeExpression.isString()) { typeExpression = cloneProps( new TypeDeclarationNode(Token.STRING, typeExpression.getString())); } typeTarget.setDeclaredTypeExpression((TypeDeclarationNode) typeExpression); } }
/** * @return a new node representing the Void type as defined by TypeScript. */ public static TypeDeclarationNode voidType() { return new TypeDeclarationNode(Token.VOID_TYPE); }
/** * Equivalent to the UNKNOWN type in Closure, expressed with {@code {?}} * @return a new node representing any type, without type checking. */ public static TypeDeclarationNode anyType() { return new TypeDeclarationNode(Token.ANY_TYPE); }
/** Returns a new node representing an index signature type. */ TypeDeclarationNode indexSignatureType( TypeDeclarationNode keyType, TypeDeclarationNode valueType) { TypeDeclarationNode node = new TypeDeclarationNode(Token.INDEX_SIGNATURE); TypeDeclarationNode first = null; first = new TypeDeclarationNode(Token.STRING_KEY, "key"); first.setDeclaredTypeExpression(keyType); node.addChildToBack(first); node.setDeclaredTypeExpression(valueType); return node; }
/** * @return a new node representing the Undefined type as defined by TypeScript. */ public static TypeDeclarationNode undefinedType() { return new TypeDeclarationNode(Token.UNDEFINED_TYPE); }
Node processRecordType(RecordTypeTree tree) { TypeDeclarationNode node = new TypeDeclarationNode(Token.RECORD_TYPE); for (ParseTree child : tree.members) { node.addChildToBack(transform(child)); } return cloneProps(node); }
/** * @return a new node representing the Undefined type as defined by TypeScript. */ public static TypeDeclarationNode undefinedType() { return new TypeDeclarationNode(Token.UNDEFINED_TYPE); }
/** * @return a new node representing the Void type as defined by TypeScript. */ public static TypeDeclarationNode voidType() { return new TypeDeclarationNode(Token.VOID_TYPE); }
/** * @return a new node representing the string built-in type. */ public static TypeDeclarationNode stringType() { return new TypeDeclarationNode(Token.STRING_TYPE); }
private void maybeProcessType(Node typeTarget, ParseTree typeTree) { if (typeTree != null) { recordJsDoc(typeTree.location, typeTarget.getJSDocInfo()); Node typeExpression = convertTypeTree(typeTree); if (typeExpression.isString()) { typeExpression = cloneProps( new TypeDeclarationNode(Token.STRING, typeExpression.getString())); } typeTarget.setDeclaredTypeExpression((TypeDeclarationNode) typeExpression); } }
/** * Equivalent to the UNKNOWN type in Closure, expressed with {@code {?}} * @return a new node representing any type, without type checking. */ public static TypeDeclarationNode anyType() { return new TypeDeclarationNode(Token.ANY_TYPE); }
/** * @return a new node representing the number built-in type. */ public static TypeDeclarationNode numberType() { return new TypeDeclarationNode(Token.NUMBER_TYPE); }
/** * Represents a function parameter that is optional. * In closure syntax, this is {@code function(?string=, number=)} * In TypeScript syntax, it is * {@code (firstName: string, lastName?: string)=>string} * @param parameterType the type of the parameter * @return a new node representing the function parameter type */ public static TypeDeclarationNode optionalParameter(TypeDeclarationNode parameterType) { return new TypeDeclarationNode(Token.OPTIONAL_PARAMETER, parameterType); } }
/** * @return a new node representing the boolean built-in type. */ public static TypeDeclarationNode booleanType() { return new TypeDeclarationNode(Token.BOOLEAN_TYPE); }
/** * Represents a function parameter that is optional. * In closure syntax, this is {@code function(?string=, number=)} * In TypeScript syntax, it is * {@code (firstName: string, lastName?: string)=>string} * @param parameterType the type of the parameter * @return a new node representing the function parameter type */ public static TypeDeclarationNode optionalParameter(TypeDeclarationNode parameterType) { return new TypeDeclarationNode(Token.OPTIONAL_PARAMETER, parameterType); } }
@Override public TypeDeclarationNode cloneNode(boolean cloneTypeExprs) { return copyNodeFields(new TypeDeclarationNode(token, str), cloneTypeExprs); } }