Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve typescript with builtins and add tsx #1277

Merged
merged 1 commit into from
Feb 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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