From 8fe85ca3fe9aa0629311bbb1ca6fbaf8b961969a Mon Sep 17 00:00:00 2001 From: ambujsahu81 Date: Wed, 21 Dec 2022 14:57:00 +0530 Subject: [PATCH] Fix query comments example in readme.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 51e6a67..334a274 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,7 @@ It is a common use case to sort the keys of a JSON file ```js const parsed = parse(`{ // b - "b": 2 + "b": 2, // a "a": 1 }`) @@ -305,14 +305,14 @@ Furthermore, a type `CommentDescriptor` is provided for enforcing properly forma ```ts import { - CommentDescriptor, CommentSymbol, parse + CommentDescriptor, CommentSymbol, parse, CommentArray } from 'comment-json' const parsed = parse(`{ /* test */ "foo": "bar" }`) // typescript only allows properly formatted symbol names here -const symbolName: CommentDescriptor: 'before-prop:foo' +const symbolName: CommentDescriptor = 'before:foo' -console.log(parsed[Symbol.for(symbolName) as CommentSymbol][0].value) +console.log((parsed as CommentArray)[Symbol.for(symbolName) as CommentSymbol][0].value) ``` In this example, casting to `Symbol.for(symbolName)` to `CommentSymbol` is mandatory.