From 51ae75a977c555ed741c312f53439afbf2ce4150 Mon Sep 17 00:00:00 2001 From: Michael Camilleri Date: Sat, 4 Apr 2020 05:12:17 +0900 Subject: [PATCH 1/2] Add code using template strings and optional chaining --- spec/visual/samples/typescript | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spec/visual/samples/typescript b/spec/visual/samples/typescript index 7379879409..be3897b743 100644 --- a/spec/visual/samples/typescript +++ b/spec/visual/samples/typescript @@ -198,3 +198,8 @@ declare module "foo" { [K in keyof IFoo]?: IFoo[K] } } + +// Template strings +const x = `Hello world ${a.b}`; +const y = `Hello world ${a?.b}`; +const z = `Hello world`; From 5491eb47f435153e5e24bd2cc67a6c1f689712e5 Mon Sep 17 00:00:00 2001 From: Michael Camilleri Date: Sat, 4 Apr 2020 05:13:07 +0900 Subject: [PATCH 2/2] Add rule for optional chaining to root state --- lib/rouge/lexers/typescript.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/rouge/lexers/typescript.rb b/lib/rouge/lexers/typescript.rb index 52f95e7695..5a4283fd59 100644 --- a/lib/rouge/lexers/typescript.rb +++ b/lib/rouge/lexers/typescript.rb @@ -19,6 +19,10 @@ class Typescript < Javascript mimetypes 'text/typescript' + prepend :root do + rule %r/[?][.]/, Punctuation + end + prepend :statement do rule %r/(#{Javascript.id_regex})(\??)(\s*)(:)/ do groups Name::Label, Punctuation, Text, Punctuation