Skip to content

Commit

Permalink
docs: tweak select example
Browse files Browse the repository at this point in the history
  • Loading branch information
aleclarson committed Dec 5, 2024
1 parent 3fd8728 commit f7fd772
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,12 @@ Note: You must not include the *node types* (i.e. the capitalized names) in the
```ts
import { select, Expr } from "@pg-nano/pg-parser"

/**
* Given an expression node of many possible types,
* check for a `typeName` field.
*/
const typeName = select(expr as Expr, 'typeName')
// Say we have an expression node of many possible types.
declare const expr: Expr

// By using the `select` function, we can access the `typeName` field
// without having to use a bunch of type guards.
const typeName = select(expr, 'typeName')
// ^? TypeName | undefined
```

Expand Down

0 comments on commit f7fd772

Please sign in to comment.