diff --git a/lib/rouge/lexers/typescript.rb b/lib/rouge/lexers/typescript.rb index 353ca7ffd5..52f95e7695 100644 --- a/lib/rouge/lexers/typescript.rb +++ b/lib/rouge/lexers/typescript.rb @@ -18,6 +18,13 @@ class Typescript < Javascript filenames '*.ts', '*.d.ts' mimetypes 'text/typescript' + + prepend :statement do + rule %r/(#{Javascript.id_regex})(\??)(\s*)(:)/ do + groups Name::Label, Punctuation, Text, Punctuation + push :expr_start + end + end end end end diff --git a/spec/visual/samples/typescript b/spec/visual/samples/typescript index 6d9511dc1d..7379879409 100644 --- a/spec/visual/samples/typescript +++ b/spec/visual/samples/typescript @@ -167,7 +167,7 @@ declare module "foo" { export interface IFoo { theObject: any; aWord: string; - aNumber: number; + aNumber?: number; } }