[gtksourceview: 5/8] typescript.lang: Add support for @ts-nocheck comment pragmas



commit 1591b5d6659d9fc47ed4730358d5d3dfbbba160b
Author: Jeffery To <jeffery to gmail com>
Date:   Fri Nov 15 04:56:08 2019 +0800

    typescript.lang: Add support for @ts-nocheck comment pragmas
    
    TypeScript 3.7 allows @ts-nocheck comments to appear in TypeScript
    files. Previously this was only respected in JavaScript files with the
    checkJs flag.

 data/language-specs/typescript.lang | 19 +++++++++++++++++++
 tests/syntax-highlighting/file.ts   | 15 +++++++++++++++
 tests/syntax-highlighting/file.tsx  | 15 +++++++++++++++
 3 files changed, 49 insertions(+)
---
diff --git a/data/language-specs/typescript.lang b/data/language-specs/typescript.lang
index d453995e..3989fd29 100644
--- a/data/language-specs/typescript.lang
+++ b/data/language-specs/typescript.lang
@@ -169,6 +169,24 @@
       </include>
     </context> <!-- /_ts-ignore-comment-pragmas-no-extend-parent -->
 
+    <!-- ## @ts-nocheck comment pragma
+
+         // @ts-nocheck
+
+         can only be preceded by comments or other triple-slash
+         directives (i.e. at the top of a file)
+         appears to be case-insensitive (cannot find code reference though)
+    -->
+
+    <context id="_ts-nocheck-comment-pragmas" style-ref="js:directive" end-at-line-end="true" 
class="comment">
+      <start case-sensitive="false" extended="true">
+        ///? \s* @ts-nocheck \%]
+      </start>
+      <include>
+        <context ref="def:in-comment"/>
+      </include>
+    </context> <!-- /_ts-nocheck-comment-pragmas -->
+
     <!-- ## Triple-slash directive
 
          /// <reference path="..."
@@ -796,6 +814,7 @@
 
     <context id="typescript" class="no-spell-check">
       <include>
+        <context ref="_ts-nocheck-comment-pragmas"/>
         <context ref="_triple-slash-directives"/>
         <context ref="js:js"/>
       </include>
diff --git a/tests/syntax-highlighting/file.ts b/tests/syntax-highlighting/file.ts
index 39f538bc..c0b4591f 100644
--- a/tests/syntax-highlighting/file.ts
+++ b/tests/syntax-highlighting/file.ts
@@ -255,6 +255,21 @@ let a: string;
 /* @ts-ignore */
 
 
+/* @ts-nocheck comment pragmas */
+
+// Valid pragmas
+//@ts-nocheck
+/// @TS-NOCHECK text here
+
+// Invalid pragmas
+// @ ts-nocheck
+//// @ts-nocheck
+/* @ts-nocheck */
+{
+    // @ts-nocheck
+}
+
+
 /* Triple-slash directives */
 
 // Valid directives
diff --git a/tests/syntax-highlighting/file.tsx b/tests/syntax-highlighting/file.tsx
index 0b44e0df..7ddc7b17 100644
--- a/tests/syntax-highlighting/file.tsx
+++ b/tests/syntax-highlighting/file.tsx
@@ -358,6 +358,21 @@ let a: string;
 /* @ts-ignore */
 
 
+/* @ts-nocheck comment pragmas */
+
+// Valid pragmas
+//@ts-nocheck
+/// @TS-NOCHECK text here
+
+// Invalid pragmas
+// @ ts-nocheck
+//// @ts-nocheck
+/* @ts-nocheck */
+{
+    // @ts-nocheck
+}
+
+
 /* Triple-slash directives */
 
 // Valid directives


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]