[gtksourceview: 3/8] typescript.lang: Add support for "asserts" type predicate



commit a6495d522d4771e929983e9701a52b9edeebeb71
Author: Jeffery To <jeffery to gmail com>
Date:   Fri Nov 15 03:58:38 2019 +0800

    typescript.lang: Add support for "asserts" type predicate
    
    Added in TypeScript 3.7.

 data/language-specs/typescript-type-expressions.lang | 5 +++++
 tests/syntax-highlighting/file.ts                    | 5 +++++
 tests/syntax-highlighting/file.tsx                   | 5 +++++
 3 files changed, 15 insertions(+)
---
diff --git a/data/language-specs/typescript-type-expressions.lang 
b/data/language-specs/typescript-type-expressions.lang
index 4570c176..ca245c61 100644
--- a/data/language-specs/typescript-type-expressions.lang
+++ b/data/language-specs/typescript-type-expressions.lang
@@ -59,6 +59,7 @@
     <!-- # Pre-primary type
 
          new () => object
+         asserts param
          keyof T
          readonly string[]
          unique symbol
@@ -69,6 +70,10 @@
         <context ref="typescript:constructor-modifier"/>
         <context ref="typescript-type-gen:type-parameters-list"/>
 
+        <context id="_asserts-type-predicates" style-ref="typescript:type-keyword">
+          <keyword>asserts</keyword>
+        </context> <!-- /_asserts-type-predicates -->
+
         <context id="_indexed-type-queries" style-ref="typescript:type-keyword">
           <keyword>keyof</keyword>
         </context> <!-- /_indexed-type-queries -->
diff --git a/tests/syntax-highlighting/file.ts b/tests/syntax-highlighting/file.ts
index c797c191..05ae9a24 100644
--- a/tests/syntax-highlighting/file.ts
+++ b/tests/syntax-highlighting/file.ts
@@ -119,6 +119,11 @@ let a: string & number;
 // Type predicate (user-defined type guard)
 function isString(x: any): x is string {}
 
+// "asserts" type predicate (for assertion functions)
+declare function assert(value: unknown): asserts value;
+declare function assertIsArrayOfStrings(obj: unknown): asserts obj is string[];
+declare function assertNonNull<T>(obj: T): asserts obj is NonNullable<T>;
+
 // Indexed type query (keyof)
 let a: keyof T;
 
diff --git a/tests/syntax-highlighting/file.tsx b/tests/syntax-highlighting/file.tsx
index 0450515e..53440f35 100644
--- a/tests/syntax-highlighting/file.tsx
+++ b/tests/syntax-highlighting/file.tsx
@@ -220,6 +220,11 @@ let a: string & number;
 // Type predicate (user-defined type guard)
 function isString(x: any): x is string {}
 
+// "asserts" type predicate (for assertion functions)
+declare function assert(value: unknown): asserts value;
+declare function assertIsArrayOfStrings(obj: unknown): asserts obj is string[];
+declare function assertNonNull<T>(obj: T): asserts obj is NonNullable<T>;
+
 // Indexed type query (keyof)
 let a: keyof T;
 


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