Commit 5de1b1f6370f9da8916d2781c6609eee0d3ce823

Mattias 2018-02-03T12:17:53

Improve typescript with builtins (#1277)

diff --git a/components/prism-typescript.js b/components/prism-typescript.js
index ce40ab9..760eff6 100644
--- a/components/prism-typescript.js
+++ b/components/prism-typescript.js
@@ -1,6 +1,7 @@
 Prism.languages.typescript = Prism.languages.extend('javascript', {
 	// From JavaScript Prism keyword list and TypeScript language spec: https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#221-reserved-words
-	'keyword': /\b(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|var|void|while|with|yield|false|true|module|declare|constructor|string|Function|any|number|boolean|Array|symbol|namespace|abstract|require|type)\b/
+	'keyword': /\b(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|var|void|while|with|yield|false|true|module|declare|constructor|namespace|abstract|require|type)\b/,
+	'builtin': /\b(?:string|Function|any|number|boolean|Array|symbol|console)\b/,
 });
 
 Prism.languages.ts = Prism.languages.typescript;
\ No newline at end of file
diff --git a/components/prism-typescript.min.js b/components/prism-typescript.min.js
index 91958f3..9a7ecfd 100644
--- a/components/prism-typescript.min.js
+++ b/components/prism-typescript.min.js
@@ -1 +1 @@
-Prism.languages.typescript=Prism.languages.extend("javascript",{keyword:/\b(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|var|void|while|with|yield|false|true|module|declare|constructor|string|Function|any|number|boolean|Array|symbol|namespace|abstract|require|type)\b/}),Prism.languages.ts=Prism.languages.typescript;
\ No newline at end of file
+Prism.languages.typescript=Prism.languages.extend("javascript",{keyword:/\b(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|var|void|while|with|yield|false|true|module|declare|constructor|namespace|abstract|require|type)\b/,builtin:/\b(?:string|Function|any|number|boolean|Array|symbol|console)\b/}),Prism.languages.ts=Prism.languages.typescript;
\ No newline at end of file
diff --git a/tests/languages/typescript/builtin_feature.test b/tests/languages/typescript/builtin_feature.test
new file mode 100644
index 0000000..f0f23f9
--- /dev/null
+++ b/tests/languages/typescript/builtin_feature.test
@@ -0,0 +1,25 @@
+string
+Function
+any
+number
+boolean
+Array
+symbol
+console
+
+----------------------------------------------------
+
+[
+	["builtin", "string"],
+	["builtin", "Function"],
+	["builtin", "any"],
+	["builtin", "number"],
+	["builtin", "boolean"],
+	["builtin", "Array"],
+	["builtin", "symbol"],
+	["builtin", "console"]
+]
+
+----------------------------------------------------
+
+Checks for builtins.
\ No newline at end of file
diff --git a/tests/languages/typescript/keyword_feature.test b/tests/languages/typescript/keyword_feature.test
index f4933d4..e308396 100644
--- a/tests/languages/typescript/keyword_feature.test
+++ b/tests/languages/typescript/keyword_feature.test
@@ -48,12 +48,6 @@ yield
 module
 declare
 constructor
-string
-Function
-any
-number
-boolean
-Array
 enum
 
 ----------------------------------------------------
@@ -109,12 +103,6 @@ enum
 	["keyword", "module"],
 	["keyword", "declare"],
 	["keyword", "constructor"],
-	["keyword", "string"],
-	["keyword", "Function"],
-	["keyword", "any"],
-	["keyword", "number"],
-	["keyword", "boolean"],
-	["keyword", "Array"],
 	["keyword", "enum"]
 ]