Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support optional props in TypeScript lexer #1393

Merged
merged 2 commits into from Jan 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/rouge/lexers/typescript.rb
Expand Up @@ -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
2 changes: 1 addition & 1 deletion spec/visual/samples/typescript
Expand Up @@ -167,7 +167,7 @@ declare module "foo" {
export interface IFoo {
theObject: any;
aWord: string;
aNumber: number;
aNumber?: number;
}
}

Expand Down