Skip to content

Commit

Permalink
Improve typescript with builtins (#1277)
Browse files Browse the repository at this point in the history
  • Loading branch information
fyrkant authored and Golmote committed Feb 3, 2018
1 parent a7665cb commit 5de1b1f
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 14 deletions.
3 changes: 2 additions & 1 deletion components/prism-typescript.js
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 1 addition & 1 deletion components/prism-typescript.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions tests/languages/typescript/builtin_feature.test
Original file line number Diff line number Diff line change
@@ -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.
12 changes: 0 additions & 12 deletions tests/languages/typescript/keyword_feature.test
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@ yield
module
declare
constructor
string
Function
any
number
boolean
Array
enum

----------------------------------------------------
Expand Down Expand Up @@ -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"]
]

Expand Down

0 comments on commit 5de1b1f

Please sign in to comment.