Skip to content

Commit e5704af

Browse files
authored
Merge pull request #171 from Fuco1/bugfix/fontify-return-type-function-type
fix(fontlock): fontify return type in a function type definition
2 parents ec2c4c1 + ba04745 commit e5704af

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
@@ -589,7 +589,11 @@ should be fontified as variable, keyword and type."
589589
(test-with-fontified-buffer
590590
"private genericArray3: SomeType<Foo[]>[];"
591591
(should (eq (get-face-at "SomeType") 'font-lock-type-face))
592-
(should (eq (get-face-at "Foo") 'font-lock-type-face))))
592+
(should (eq (get-face-at "Foo") 'font-lock-type-face)))
593+
594+
(test-with-fontified-buffer
595+
"const f: () => SomeType = () => {}"
596+
(should (eq (get-face-at "SomeType") 'font-lock-type-face))))
593597

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

typescript-mode.el

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2011,9 +2011,10 @@ This performs fontification according to `typescript--class-styles'."
20112011
;; - private genericArray: SomeType<Foo>[]
20122012
;; - function testFunc(): SomeType<> {
20132013
;; - function testFunc(a): a is SomeType<> {
2014+
;; - () => SomeType
20142015
;; TODO: namespaced classes!
20152016
,(list
2016-
(concat ":\\s-\\(?:\\s-*\\(" typescript--name-re "\\)\\s-*\\(is\\)\\s-*\\)?" "\\(" typescript--type-name-re "\\)\\(<" typescript--type-name-re ">\\)?\\(\[\]\\)?\\([,;]\\)?\\s-*{?")
2017+
(concat "\\(?::\\|=>\\)\\s-\\(?:\\s-*\\(" typescript--name-re "\\)\\s-*\\(is\\)\\s-*\\)?" "\\(" typescript--type-name-re "\\)\\(<" typescript--type-name-re ">\\)?\\(\[\]\\)?\\([,;]\\)?\\s-*{?")
20172018
'(1 'font-lock-variable-name-face nil t)
20182019
'(2 'font-lock-keyword-face nil t)
20192020
'(3 'font-lock-type-face))

0 commit comments

Comments
 (0)