Skip to content

Commit 8fe85ca

Browse files
committed
Fix query comments example in readme.md
1 parent ffec399 commit 8fe85ca

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ It is a common use case to sort the keys of a JSON file
9292
```js
9393
const parsed = parse(`{
9494
// b
95-
"b": 2
95+
"b": 2,
9696
// a
9797
"a": 1
9898
}`)
@@ -305,14 +305,14 @@ Furthermore, a type `CommentDescriptor` is provided for enforcing properly forma
305305
306306
```ts
307307
import {
308-
CommentDescriptor, CommentSymbol, parse
308+
CommentDescriptor, CommentSymbol, parse, CommentArray
309309
} from 'comment-json'
310310

311311
const parsed = parse(`{ /* test */ "foo": "bar" }`)
312312
// typescript only allows properly formatted symbol names here
313-
const symbolName: CommentDescriptor: 'before-prop:foo'
313+
const symbolName: CommentDescriptor = 'before:foo'
314314

315-
console.log(parsed[Symbol.for(symbolName) as CommentSymbol][0].value)
315+
console.log((parsed as CommentArray<string>)[Symbol.for(symbolName) as CommentSymbol][0].value)
316316
```
317317
318318
In this example, casting to `Symbol.for(symbolName)` to `CommentSymbol` is mandatory.

0 commit comments

Comments
 (0)