Merge pull request #483 from vkbansal/typescript Added TypeScript definition
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
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>