Improve typescript with builtins (#1277)
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 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
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"]
]