From dc9ad22ec4c5ab51e4e0d672dc01757db88c7c85 Mon Sep 17 00:00:00 2001 From: PulsarBlow Date: Sat, 23 Feb 2013 23:40:40 +0100 Subject: [PATCH] TypeScript language support Signed-off-by: PulsarBlow --- lib/linguist/languages.yml | 8 ++++++++ samples/TypeScript/classes.ts | 28 ++++++++++++++++++++++++++++ samples/TypeScript/empty.ts | 0 samples/TypeScript/hello.ts | 1 + test/test_blob.rb | 3 +++ test/test_language.rb | 4 ++++ 6 files changed, 44 insertions(+) create mode 100644 samples/TypeScript/classes.ts create mode 100644 samples/TypeScript/empty.ts create mode 100644 samples/TypeScript/hello.ts diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index a38748ec..54df8154 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -1228,6 +1228,14 @@ Twig: lexer: HTML+Django/Jinja primary_extension: .twig +TypeScript: + type: programming + color: "#31859c" + lexer: Text only + aliases: + - ts + primary_extension: .ts + VHDL: type: programming lexer: vhdl diff --git a/samples/TypeScript/classes.ts b/samples/TypeScript/classes.ts new file mode 100644 index 00000000..545c6cf5 --- /dev/null +++ b/samples/TypeScript/classes.ts @@ -0,0 +1,28 @@ +class Animal { + constructor(public name) { } + move(meters) { + alert(this.name + " moved " + meters + "m."); + } +} + +class Snake extends Animal { + constructor(name) { super(name); } + move() { + alert("Slithering..."); + super.move(5); + } +} + +class Horse extends Animal { + constructor(name) { super(name); } + move() { + alert("Galloping..."); + super.move(45); + } +} + +var sam = new Snake("Sammy the Python") +var tom: Animal = new Horse("Tommy the Palomino") + +sam.move() +tom.move(34) diff --git a/samples/TypeScript/empty.ts b/samples/TypeScript/empty.ts new file mode 100644 index 00000000..e69de29b diff --git a/samples/TypeScript/hello.ts b/samples/TypeScript/hello.ts new file mode 100644 index 00000000..4b65a573 --- /dev/null +++ b/samples/TypeScript/hello.ts @@ -0,0 +1 @@ +console.log "Hello, World!" diff --git a/test/test_blob.rb b/test/test_blob.rb index 3569a8ec..827a002a 100644 --- a/test/test_blob.rb +++ b/test/test_blob.rb @@ -175,6 +175,9 @@ class TestBlob < Test::Unit::TestCase # CoffeeScript-generated JS # TODO + # TypeScript-generated JS + # TODO + # PEG.js-generated parsers assert blob("JavaScript/parser.js").generated? diff --git a/test/test_language.rb b/test/test_language.rb index 17b2a83a..f83a7218 100644 --- a/test/test_language.rb +++ b/test/test_language.rb @@ -109,6 +109,7 @@ class TestLanguage < Test::Unit::TestCase assert_equal Language['Shell'], Language.find_by_alias('shell') assert_equal Language['Shell'], Language.find_by_alias('zsh') assert_equal Language['TeX'], Language.find_by_alias('tex') + assert_equal Language['TypeScript'], Language.find_by_alias('ts') assert_equal Language['VimL'], Language.find_by_alias('vim') assert_equal Language['VimL'], Language.find_by_alias('viml') assert_equal Language['reStructuredText'], Language.find_by_alias('rst') @@ -186,6 +187,7 @@ class TestLanguage < Test::Unit::TestCase assert_equal :programming, Language['PowerShell'].type assert_equal :programming, Language['Python'].type assert_equal :programming, Language['Ruby'].type + assert_equal :programming, Language['TypeScript'].type end def test_markup @@ -279,6 +281,7 @@ class TestLanguage < Test::Unit::TestCase assert_equal '#701516', Language['Ruby'].color assert_equal '#3581ba', Language['Python'].color assert_equal '#f15501', Language['JavaScript'].color + assert_equal '#31859c', Language['TypeScript'].color end def test_colors @@ -317,6 +320,7 @@ class TestLanguage < Test::Unit::TestCase assert_equal '.js', Language['JavaScript'].primary_extension assert_equal '.coffee', Language['CoffeeScript'].primary_extension assert_equal '.t', Language['Turing'].primary_extension + assert_equal '.ts', Language['TypeScript'].primary_extension # This is a nasty requirement, but theres some code in GitHub that # expects this. Really want to drop this.