/** * Add optional parameters of the given type to the end of the param list. * @param types Types for each optional parameter. The builder will make them * undefine-able. * @return False if this is called after var args are added. */ public boolean addOptionalParams(JSType ...types) { if (hasVarArgs()) { return false; } for (JSType type : types) { newParameter(registry.createOptionalType(type)).setOptionalArg(true); } return true; }
/** * Add optional parameters of the given type to the end of the param list. * @param types Types for each optional parameter. The builder will make them * undefine-able. * @return False if this is called after var args are added. */ public boolean addOptionalParams(JSType ...types) { if (hasVarArgs()) { return false; } for (JSType type : types) { newParameter(registry.createOptionalType(type)).setOptionalArg(true); } return true; }
/** * Add variable arguments to the end of the parameter list. * @return False if this is called after var args are added. */ public boolean addVarArgs(JSType type) { if (hasVarArgs()) { return false; } // There are two types of variable argument functions: // 1) Programmer-defined var args // 2) Native bottom types that can accept any argument. // For the first one, "undefined" is a valid value for all arguments. // For the second, we do not want to cast it up to undefined. if (!type.isEmptyType()) { type = registry.createOptionalType(type); } newParameter(type).setVarArgs(true); return true; }
return createOptionalType( createFromTypeNodesInternal( n.getFirstChild(), sourceName, scope)); return createOptionalType( createFromTypeNodesInternal( n.getFirstChild(), sourceName, scope));
return createOptionalType( createFromTypeNodesInternal( n.getFirstChild(), sourceName, scope, recordUnresolvedTypes));