Skip to content

Commit

Permalink
Merge pull request #31 from HairyRabbit/fix-28
Browse files Browse the repository at this point in the history
Fixed #28
  • Loading branch information
HairyRabbit authored Dec 28, 2017
2 parents ae15ba0 + aece5a6 commit 65d3df8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 5 additions & 2 deletions js2-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -12973,18 +12973,21 @@ TODO: free semi supports."
(let ((pos (js2-current-token-beg))
(_ (js2-must-match-name "msg.unnamed.type.alias.decl"))
(name (js2-create-name-node t))
type-params)
type-params node)
(js2-set-face (js2-node-pos name) (js2-node-end name)
'font-lock-function-name-face 'record)
;; parse type params after name, e.g. type a<T>
(when (= (js2-peek-token) js2-LT)
(setq type-params (js2-parse-type-params)))
(js2-must-match js2-ASSIGN "msg.syntax")
(setq js2-in-type t
node (js2-create-type-node t)
js2-in-type nil)
(make-js2-type-alias-node :pos pos
:len (- (js2-current-token-end) pos)
:name name
:type-params type-params
:bindings (js2-create-type-node t))))
:bindings node)))

(defun js2-parse-opaque-type-alias ()
"Parse type alias declatation, e.g. opaque type a<b> = c"
Expand Down
3 changes: 3 additions & 0 deletions tests/flow.el
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,9 @@ the test."
(js2-deftest-parse type-alias
"type a = b;")

(js2-deftest-parse type-alias-with-generic-type
"type a = b<c<d<e>>>;")

(js2-deftest-parse type-alias-with-type-params
"type a<b> = c;")

Expand Down

0 comments on commit 65d3df8

Please sign in to comment.