* Asserts that the node is of the given type and returns it with stricter * typing. Throws if the node's type does not match.
(node, type)
| 6008 | * typing. Throws if the node's type does not match. |
| 6009 | */ |
| 6010 | function assertNodeType(node, type) { |
| 6011 | var typedNode = checkNodeType(node, type); |
| 6012 | |
| 6013 | if (!typedNode) { |
| 6014 | throw new Error("Expected node of type " + type + ", but got " + (node ? "node of type " + node.type : String(node))); |
| 6015 | } // $FlowFixMe: Unsure why. |
| 6016 | |
| 6017 | |
| 6018 | return typedNode; |
| 6019 | } |
| 6020 | /** |
| 6021 | * Returns the node more strictly typed iff it is of the given type. Otherwise, |
| 6022 | * returns null. |
no test coverage detected