Skip to content
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
13 changes: 13 additions & 0 deletions typescript-mode-general-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,19 @@ a severity set to WARNING, no rule name."
" * @param {Something} bar A parameter. References [[moo]] and [[foo]].
* @param second May hold ``x`` or ``y``.")

(ert-deftest font-lock/interface-builtin-key-context-unfontify ()
"Builtins should not be fontified when they are in object or
interface key context."
(test-with-fontified-buffer
"interface Foo { type: number; unknown: string; foo: boolean }"
(should (eq (get-face-at "type") 'default))
(should (eq (get-face-at "unknown") 'default)))

(test-with-fontified-buffer
"const x = { type: 4; unknown: 'bar'; foo: true }"
(should (eq (get-face-at "type") 'default))
(should (eq (get-face-at "unknown") 'default))))

(ert-deftest font-lock/documentation-in-documentation-comments ()
"Documentation in documentation comments should be fontified as
documentation."
Expand Down
8 changes: 8 additions & 0 deletions typescript-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -1737,6 +1737,14 @@ and searches for the next token to be highlighted."
`(
,@typescript--font-lock-keywords-2

;; Remove the fontification of keywords and built-ins when they
;; are keys in an interface, object or class.
(,(rx "{")
(,(concat "\\(" typescript--keyword-re "\\):")
(save-excursion (ignore-errors (up-list)) (point))
nil
(1 'default t t)))

(typescript--jsdoc-param-matcher (1 'typescript-jsdoc-tag t t)
(2 'typescript-jsdoc-type t t)
(3 'typescript-jsdoc-value t t))
Expand Down