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

Enhance definitions in TypeScript component #1522

Merged
merged 5 commits into from
Oct 18, 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
6 changes: 3 additions & 3 deletions components/prism-typescript.js
Original file line number Diff line number Diff line change
@@ -1,7 +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|module|declare|constructor|namespace|abstract|require|type)\b/,
'builtin': /\b(?:string|Function|any|number|boolean|Array|symbol|console)\b/,
'keyword': /\b(?:abstract|as|async|await|break|case|catch|class|const|constructor|continue|debugger|declare|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|is|keyof|let|module|namespace|new|null|of|package|private|protected|public|readonly|return|require|set|static|super|switch|this|throw|try|type|typeof|var|void|while|with|yield)\b/,
'builtin': /\b(?:string|Function|any|number|boolean|Array|symbol|console|Promise|unknown|never)\b/,
});

Prism.languages.ts = Prism.languages.typescript;
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.

8 changes: 7 additions & 1 deletion tests/languages/typescript/builtin_feature.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ boolean
Array
symbol
console
Promise
unknown
never

----------------------------------------------------

Expand All @@ -17,7 +20,10 @@ console
["builtin", "boolean"],
["builtin", "Array"],
["builtin", "symbol"],
["builtin", "console"]
["builtin", "console"],
["builtin", "Promise"],
["builtin", "unknown"],
["builtin", "never"]
]

----------------------------------------------------
Expand Down
40 changes: 31 additions & 9 deletions tests/languages/typescript/keyword_feature.test
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
abstract
as
async
await
break
case
catch
class;
const
constructor
continue
debugger
declare
default
delete
do
Expand All @@ -14,6 +20,7 @@ export
extends;
finally
for
from
function
get
if
Expand All @@ -22,42 +29,52 @@ import
in
instanceof;
interface;
is
keyof
let
module
namespace
new;
null
of
package
private
protected
public
readonly
return
require
set
static
super
switch
this
throw
try
type
typeof
var
void
while
with
yield
module
declare
constructor
enum
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why were these removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not removed, just sorted alphabetically. I've added the missing cases too.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see. enum appears twice on the list, so I didn't see it added.


----------------------------------------------------

[
["keyword", "abstract"],
["keyword", "as"],
["keyword", "async"],
["keyword", "await"],
["keyword", "break"],
["keyword", "case"],
["keyword", "catch"],
["keyword", "class"], ["punctuation", ";"],
["keyword", "const"],
["keyword", "constructor"],
["keyword", "continue"],
["keyword", "debugger"],
["keyword", "declare"],
["keyword", "default"],
["keyword", "delete"],
["keyword", "do"],
Expand All @@ -67,6 +84,7 @@ enum
["keyword", "extends"], ["punctuation", ";"],
["keyword", "finally"],
["keyword", "for"],
["keyword", "from"],
["keyword", "function"],
["keyword", "get"],
["keyword", "if"],
Expand All @@ -75,31 +93,35 @@ enum
["keyword", "in"],
["keyword", "instanceof"], ["punctuation", ";"],
["keyword", "interface"], ["punctuation", ";"],
["keyword", "is"],
["keyword", "keyof"],
["keyword", "let"],
["keyword", "module"],
["keyword", "namespace"],
["keyword", "new"], ["punctuation", ";"],
["keyword", "null"],
["keyword", "of"],
["keyword", "package"],
["keyword", "private"],
["keyword", "protected"],
["keyword", "public"],
["keyword", "readonly"],
["keyword", "return"],
["keyword", "require"],
["keyword", "set"],
["keyword", "static"],
["keyword", "super"],
["keyword", "switch"],
["keyword", "this"],
["keyword", "throw"],
["keyword", "try"],
["keyword", "type"],
["keyword", "typeof"],
["keyword", "var"],
["keyword", "void"],
["keyword", "while"],
["keyword", "with"],
["keyword", "yield"],
["keyword", "module"],
["keyword", "declare"],
["keyword", "constructor"],
["keyword", "enum"]
["keyword", "yield"]
]

----------------------------------------------------
Expand Down