Commit 0dde9e25 authored by Nuno Martins's avatar Nuno Martins Committed by Christian Hergert

typescript.lang: missing keywords; add test file

- Adds missing keywords and basic type to the TS lang file.
- Adds TS utility types.
- Adds TS test file.
parent 502ee735
......@@ -36,23 +36,30 @@
<style id="keyword" name="Keyword" map-to="def:keyword"/>
<style id="basic-type" name="Basic Data Type" map-to="def:type"/>
<style id="utility-type" name="Utility Type" map-to="def:function"/>
<!-- TS specific stuff (i.e. stuff which is not JS) -->
<context id="ts-proper">
<!-- From: -->
<context id="keywords" style-ref="keyword">
......@@ -65,8 +72,25 @@
<!-- From: -->
<context id="utility-types" style-ref="utility-type">
// Declarations
declare var v: any;
// Namespaces
namespace N {}
// Modules
declare module '*.txt' {
export const txt: string;
// Types
let num: number = 1;
let str: string = 'str';
let bool: boolean = true;
let obj: object = {};
let sym: symbol = Symbol();
let something: any;
let dunno: unknown;
let none: null = null;
let undef: undefined = undefined;
// Void type
function nothing(): void {
// Never type
function err(): never {
throw new Error();
// Custom types
type T = Array<string | number>;
type Keys = keyof {a: number; b: number};
type Inferred<T> = T extends {a: infer U; b: infer U} ? U : never;
// Utility types
let part: Partial<{a: number; b: number}>;
let ro: Readonly<string[]>;
let rec: Record<string, any>;
let pick: Pick<{a: number; b: number}, 'a'>;
let omit: Omit<{a: number; b: number}, 'b'>;
let exc: Exclude<'a' | 'b' | 'c', 'a'>;
let ext: Extract<'a' | 'b' | 'c', 'a' | 'f'>;
let nonNull: NonNullable<string | null>;
let retT: ReturnType<() => string>;
let inst: InstanceType<typeof Number>;
let req: Required<{a?: number; b?: string}>;
let thisT: ThisType<any>;
// Interfaces
interface I {
prop: T;
interface II extends I {
readonly r: string;
// Classes
abstract class C implements II {
prop: T;
readonly r: string;
public pub: number;
protected prot: number;
private priv: number;
constructor(private priv2: string) {}
public abstract abst(): void;
// Enums
enum Dir {
Up = 1,
const enum E {
Yes = 1,
No = Yes - 1,
// Type guards
function isNumber(n: any): n is number {
return typeof n === 'number';
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment