Commit b6183ff90bf320f83457a890f9bf9abd57cb0bec

Lea Verou 2015-01-20T11:41:48

Merge pull request #483 from vkbansal/typescript Added TypeScript definition

diff --git a/components.js b/components.js
index b19b236..e9483b7 100644
--- a/components.js
+++ b/components.js
@@ -292,6 +292,11 @@ var components = {
 			"title": "React JSX",
 			"require": ["markup", "javascript"],
 			"owner": "vkbansal"
+		},
+		"typescript":{
+			"title": "TypeScript",
+			"require": "javascript",
+			"owner": "vkbansal"
 		}
 	},
 	"plugins": {
diff --git a/components/prism-typescript.js b/components/prism-typescript.js
new file mode 100755
index 0000000..54b8e7c
--- /dev/null
+++ b/components/prism-typescript.js
@@ -0,0 +1,3 @@
+Prism.languages.typescript = Prism.languages.extend('javascript', {
+	'keyword': /\b(break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|function|get|if|implements|import|in|instanceof|interface|let|new|null|package|private|protected|public|return|set|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield|module|declare|constructor|string|Function|any|number|boolean|Array|enum)\b/g
+});
diff --git a/components/prism-typescript.min.js b/components/prism-typescript.min.js
new file mode 100755
index 0000000..d3deaef
--- /dev/null
+++ b/components/prism-typescript.min.js
@@ -0,0 +1 @@
+Prism.languages.typescript=Prism.languages.extend("javascript",{keyword:/\b(break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|function|get|if|implements|import|in|instanceof|interface|let|new|null|package|private|protected|public|return|set|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield|module|declare|constructor|string|Function|any|number|boolean|Array|enum)\b/g});
\ No newline at end of file
diff --git a/examples/prism-typescript.html b/examples/prism-typescript.html
new file mode 100755
index 0000000..3903a16
--- /dev/null
+++ b/examples/prism-typescript.html
@@ -0,0 +1,31 @@
+<h1>TypeScript</h1>
+<p>To use this language, use the class "language-typescript".</p>
+
+<h2>Full example</h2>
+<pre><code>interface SearchFunc {
+  (source: string, subString: string): boolean;
+}
+
+var mySearch: SearchFunc;
+mySearch = function(source: string, subString: string) {
+  var result = source.search(subString);
+  if (result == -1) {
+    return false;
+  }
+  else {
+    return true;
+  }
+}
+
+class Greeter {
+    greeting: string;
+    constructor(message: string) {
+        this.greeting = message;
+    }
+    greet() {
+        return "Hello, " + this.greeting;
+    }
+}
+
+var greeter = new Greeter("world");
+</code></pre>