From 9266cbd73cf619fd764b04f5e7eb074515f8fc93 Mon Sep 17 00:00:00 2001 From: Evan R Date: Mon, 13 May 2024 05:09:57 -0700 Subject: [PATCH] Adding type operators satisfies and as (#2014) --- lib/rouge/lexers/javascript.rb | 2 +- lib/rouge/lexers/typescript/common.rb | 9 +++++++++ spec/visual/samples/typescript | 17 +++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/lib/rouge/lexers/javascript.rb b/lib/rouge/lexers/javascript.rb index c844c2cf1b..ce11ad728f 100644 --- a/lib/rouge/lexers/javascript.rb +++ b/lib/rouge/lexers/javascript.rb @@ -100,7 +100,7 @@ def self.detect?(text) def self.keywords @keywords ||= Set.new %w( - as async await break case catch continue debugger default delete + async await break case catch continue debugger default delete do else export finally from for if import in instanceof new of return super switch this throw try typeof void while yield ) diff --git a/lib/rouge/lexers/typescript/common.rb b/lib/rouge/lexers/typescript/common.rb index b0e23b03ce..ec45efcc50 100644 --- a/lib/rouge/lexers/typescript/common.rb +++ b/lib/rouge/lexers/typescript/common.rb @@ -37,6 +37,15 @@ def self.extended(base) base.prepend :root do rule %r/[?][.]/, base::Punctuation rule %r/[?]{2}/, base::Operator + + # Positive Examples: + # const cat = { name: "Garfield" } satisfies Person; + # import {something as thingy} from 'module' + # export { foo as default } + # ...spreadOperator as const; + # Negative Example: + # cy.get('kitten').as('friend') + rule %r{(?