Noticed that the type definitions for NodeTypeUtil.isTypeOf expects the string arguments for types to be spread, but it actually expects an array of strings.
The type definition expect the following:
const TYPES = [
NodeTypeUtil.PAGE_TYPE,
NodeTypeUtil.COLLABORATION_GROUP_PAGE_TYPE,
NodeTypeUtil.COLLABORATION_GROUP_TYPE,
NodeTypeUtil.STRUCTURE_PAGE_TYPE,
];
function isValidType(node: Node) {
return NodeTypeUtil.isTypeOf(node, ...TYPES);
}
But then you get a runtime error:
Can't find method com.sun.proxy.$Proxy175.isTypeOf(senselogic.sitevision.content.jcr.node.NodeImpl,string,string,string,string). (<sitevision>#338)
The following works, but reports a TypeScript error.
const TYPES = [
NodeTypeUtil.PAGE_TYPE,
NodeTypeUtil.COLLABORATION_GROUP_PAGE_TYPE,
NodeTypeUtil.COLLABORATION_GROUP_TYPE,
NodeTypeUtil.STRUCTURE_PAGE_TYPE,
];
function isValidType(node: Node) {
return NodeTypeUtil.isTypeOf(node, TYPES);
}
Argument of type '[("sv:page" | "sv:collaborationGroupPage" | "sv:collaborationGroup" | "sv:structurePage")[]]' is not assignable to parameter of type 'String[] | string[]'.
Type '[("sv:page" | "sv:collaborationGroupPage" | "sv:collaborationGroup" | "sv:structurePage")[]]' is not assignable to type 'string[]'.
Type '("sv:page" | "sv:collaborationGroupPage" | "sv:collaborationGroup" | "sv:structurePage")[]' is not assignable to type 'string'.
The type definition for isTypeOf should propably be updated to:
/**
* Checks a node against multiple node type names to see if any of them match.
* @param aNode the node to be checked
* @param aPrimaryNodeTypes the primary node type names <code>aNode</code> should be checked against
* @return whether primary node type of <code>aNode</code> matches any of the types in <code>aPrimaryNodeTypes</code>
*/
- isTypeOf(aNode: Node, ...aPrimaryNodeTypes: String[] | string[]): boolean;
+ isTypeOf(aNode: Node, aPrimaryNodeTypes: String[] | string[]): boolean;
Noticed that the type definitions for NodeTypeUtil.isTypeOf expects the string arguments for types to be spread, but it actually expects an array of strings.
The type definition expect the following:
But then you get a runtime error:
The following works, but reports a TypeScript error.
The type definition for isTypeOf should propably be updated to: