Skip to content

Commit

Permalink
Add support for nullish coalescing operator
Browse files Browse the repository at this point in the history
  • Loading branch information
pyrmont committed Jun 2, 2020
1 parent 30fc93f commit 63000d6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/rouge/lexers/typescript/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def builtins
def self.extended(base)
base.prepend :root do
rule %r/[?][.]/, base::Punctuation
rule %r/[?]{2}/, base::Operator
end

base.prepend :statement do
Expand Down
4 changes: 4 additions & 0 deletions spec/visual/samples/typescript
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,7 @@ declare module "foo" {
const x = `Hello world ${a.b}`;
const y = `Hello world ${a?.b}`;
const z = `Hello world`;

// Nullish coalescing in template strings
const content = `Value is ${value ?? 'not set'}`;
const description = "Highlighting is broken now";

0 comments on commit 63000d6

Please sign in to comment.