Skip to content

Commit ba04745

Browse files
committed
fix(fontlock): fontify return type in a function type definition
1 parent 83bf47e commit ba04745

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

typescript-mode-general-tests.el

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,11 @@ should be fontified as variable, keyword and type."
565565
(test-with-fontified-buffer
566566
"private genericArray3: SomeType<Foo[]>[];"
567567
(should (eq (get-face-at "SomeType") 'font-lock-type-face))
568-
(should (eq (get-face-at "Foo") 'font-lock-type-face))))
568+
(should (eq (get-face-at "Foo") 'font-lock-type-face)))
569+
570+
(test-with-fontified-buffer
571+
"const f: () => SomeType = () => {}"
572+
(should (eq (get-face-at "SomeType") 'font-lock-type-face))))
569573

570574
(ert-deftest font-lock/type-names-level4-namespaces ()
571575
"Namespaced Typenames should be highlighted in declarations"

typescript-mode.el

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2003,9 +2003,10 @@ This performs fontification according to `typescript--class-styles'."
20032003
;; - private genericArray: SomeType<Foo>[]
20042004
;; - function testFunc(): SomeType<> {
20052005
;; - function testFunc(a): a is SomeType<> {
2006+
;; - () => SomeType
20062007
;; TODO: namespaced classes!
20072008
,(list
2008-
(concat ":\\s-\\(?:\\s-*\\(" typescript--name-re "\\)\\s-*\\(is\\)\\s-*\\)?" "\\(" typescript--type-name-re "\\)\\(<" typescript--type-name-re ">\\)?\\(\[\]\\)?\\([,;]\\)?\\s-*{?")
2009+
(concat "\\(?::\\|=>\\)\\s-\\(?:\\s-*\\(" typescript--name-re "\\)\\s-*\\(is\\)\\s-*\\)?" "\\(" typescript--type-name-re "\\)\\(<" typescript--type-name-re ">\\)?\\(\[\]\\)?\\([,;]\\)?\\s-*{?")
20092010
'(1 'font-lock-variable-name-face nil t)
20102011
'(2 'font-lock-keyword-face nil t)
20112012
'(3 'font-lock-type-face))

0 commit comments

Comments
 (0)