Skip to content

Commit

Permalink
fix(Typescript guards): Allow isA to take a possibly undefined node
Browse files Browse the repository at this point in the history
  • Loading branch information
nokome committed Jan 21, 2020
1 parent e3b83c9 commit 2e5dc24
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ts/util/guards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,12 @@ export const is = <Ts extends Entity>(type: keyof TypeMap<Ts>) => {
*
* e.g. `isA('Paragraph', node)`
*
* @param type The type to test for
* @param type The name of the type to test for
* @param node The node being tested
*/
export const isA = <K extends keyof Types>(
type: K,
node: Node
node: Node | undefined
): node is Types[K] => {
return isEntity(node) && node.type === type
}
Expand Down

0 comments on commit 2e5dc24

Please sign in to comment.