Skip to content

Commit

Permalink
TypeScript: add the "awaited" type operator
Browse files Browse the repository at this point in the history
Summary: Add the new keyword "awaited": microsoft/TypeScript#35998

Reviewers: #framework_syntax_highlighting, dhaumann, cullmann

Reviewed By: #framework_syntax_highlighting, cullmann

Subscribers: kwrite-devel, kde-frameworks-devel

Tags: #kate, #frameworks

Differential Revision: https://phabricator.kde.org/D28814
  • Loading branch information
nibags authored and christoph-cullmann committed Apr 15, 2020
1 parent 0f8c36b commit 1f1f031
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 2 deletions.
9 changes: 9 additions & 0 deletions autotests/folding/test.ts.fold
Original file line number Diff line number Diff line change
Expand Up @@ -278,3 +278,12 @@ export * from "AnotherModule";
export <beginfold id='1'>{</beginfold id='1'> k as m, l <endfold id='1'>}</endfold id='1'> from "AnotherModule";
export type <beginfold id='1'>{</beginfold id='1'> T <endfold id='1'>}</endfold id='1'>;
export type <beginfold id='1'>{</beginfold id='1'> U <endfold id='1'>}</endfold id='1'> from "AnotherModule";

// 'awaited' type operator: https://github.com/microsoft/TypeScript/pull/35998
let v1: awaited number;
let v2: awaited Promise<number>;
function f7<U>() <beginfold id='1'>{</beginfold id='1'>
let v0: awaited U;
let v1: awaited Promise<U>;

<endfold id='1'>}</endfold id='1'>
9 changes: 9 additions & 0 deletions autotests/html/test.ts.html
Original file line number Diff line number Diff line change
Expand Up @@ -284,4 +284,13 @@
<span style="color:#ff5500;">export</span> { k <span style="color:#ff5500;">as</span> m, l } <span style="color:#ff5500;">from</span> <span style="color:#bf0303;">&quot;AnotherModule&quot;</span>;
<span style="color:#ff5500;">export type</span> { T };
<span style="color:#ff5500;">export type</span> { U } <span style="color:#ff5500;">from</span> <span style="color:#bf0303;">&quot;AnotherModule&quot;</span>;

<span style="color:#898887;">// 'awaited' type operator: https://github.com/microsoft/TypeScript/pull/35998</span>
<span style="font-weight:bold;font-style:italic;">let</span> v1: <span style="font-weight:bold;">awaited</span> <span style="color:#0057ae;">number</span>;
<span style="font-weight:bold;font-style:italic;">let</span> v2: <span style="font-weight:bold;">awaited</span> <span style="color:#644a9b;font-weight:bold;">Promise</span>&lt;<span style="color:#0057ae;">number</span>&gt;;
<span style="font-weight:bold;">function</span> <span style="color:#644a9b;">f7</span>&lt;U&gt;() {
<span style="font-weight:bold;font-style:italic;">let</span> v0: <span style="font-weight:bold;">awaited</span> U;
<span style="font-weight:bold;font-style:italic;">let</span> v1: <span style="font-weight:bold;">awaited</span> <span style="color:#644a9b;font-weight:bold;">Promise</span>&lt;U&gt;;

}
</pre></body></html>
9 changes: 9 additions & 0 deletions autotests/input/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,3 +278,12 @@ export * from "AnotherModule";
export { k as m, l } from "AnotherModule";
export type { T };
export type { U } from "AnotherModule";

// 'awaited' type operator: https://github.com/microsoft/TypeScript/pull/35998
let v1: awaited number;
let v2: awaited Promise<number>;
function f7<U>() {
let v0: awaited U;
let v1: awaited Promise<U>;

}
9 changes: 9 additions & 0 deletions autotests/reference/test.ts.ref
Original file line number Diff line number Diff line change
Expand Up @@ -278,3 +278,12 @@
<Module>export</Module><Normal Text> { </Normal Text><Normal Text>k </Normal Text><Module>as</Module><Normal Text> </Normal Text><Normal Text>m</Normal Text><Symbol>,</Symbol><Normal Text> </Normal Text><Normal Text>l </Normal Text><Normal Text>} </Normal Text><Module>from</Module><Normal Text> </Normal Text><String>"AnotherModule"</String><Symbol>;</Symbol><br/>
<Module>export type</Module><Normal Text> { </Normal Text><Normal Text>T </Normal Text><Normal Text>}</Normal Text><Symbol>;</Symbol><br/>
<Module>export type</Module><Normal Text> { </Normal Text><Normal Text>U </Normal Text><Normal Text>} </Normal Text><Module>from</Module><Normal Text> </Normal Text><String>"AnotherModule"</String><Symbol>;</Symbol><br/>
<Normal Text></Normal Text><br/>
<Comment>// 'awaited' type operator: https://github.com/microsoft/TypeScript/pull/35998</Comment><br/>
<Reserved>let</Reserved><Normal Text> </Normal Text><Parameter>v1</Parameter><Symbol>:</Symbol><Normal Text> </Normal Text><Keyword>awaited</Keyword><Normal Text> </Normal Text><Types>number</Types><Symbol>;</Symbol><br/>
<Reserved>let</Reserved><Normal Text> </Normal Text><Parameter>v2</Parameter><Symbol>:</Symbol><Normal Text> </Normal Text><Keyword>awaited</Keyword><Normal Text> </Normal Text><Built-in Objects>Promise</Built-in Objects><Symbol><</Symbol><Types>number</Types><Symbol>></Symbol><Symbol>;</Symbol><br/>
<Keyword>function</Keyword><Normal Text> </Normal Text><Function Declaration>f7</Function Declaration><Symbol><</Symbol><Normal Text>U</Normal Text><Symbol>></Symbol><Normal Text>() {</Normal Text><br/>
<Normal Text> </Normal Text><Reserved>let</Reserved><Normal Text> </Normal Text><Parameter>v0</Parameter><Symbol>:</Symbol><Normal Text> </Normal Text><Keyword>awaited</Keyword><Normal Text> </Normal Text><Normal Text>U</Normal Text><Symbol>;</Symbol><br/>
<Normal Text> </Normal Text><Reserved>let</Reserved><Normal Text> </Normal Text><Parameter>v1</Parameter><Symbol>:</Symbol><Normal Text> </Normal Text><Keyword>awaited</Keyword><Normal Text> </Normal Text><Built-in Objects>Promise</Built-in Objects><Symbol><</Symbol><Normal Text>U</Normal Text><Symbol>></Symbol><Symbol>;</Symbol><br/>
<Normal Text></Normal Text><br/>
<Normal Text>}</Normal Text><br/>
6 changes: 4 additions & 2 deletions data/syntax/typescript.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
Attributes: path, types, no-default-lib, name
Change log:
* v10 [2020-04-13]: Add the 'awaited' type operator.
* v9 [2020-02-23]: Add private-named instance fields and type-only imports/exports.
Improve conditional expressions.
* v8 [2019-12-12]: Add "bigint" primitive type.
Expand All @@ -59,7 +60,7 @@
-->

<language name="TypeScript"
version="9"
version="10"
kateversion="5.53"
section="Scripts"
extensions="*.ts"
Expand Down Expand Up @@ -112,7 +113,8 @@
<list name="types_operator_expression">
<item>keyof</item>
<item>infer</item>
<!-- Also: is, typeof -->
<item>awaited</item>
<!-- Also: typeof, readonly -->
</list>
<!-- Datatypes & Primitive Types -->
<list name="types">
Expand Down

0 comments on commit 1f1f031

Please sign in to comment.