Skip to content

Commit

Permalink
Fix #17
Browse files Browse the repository at this point in the history
  • Loading branch information
HairyRabbit committed Dec 26, 2017
1 parent 6431b70 commit 7237d04
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
17 changes: 13 additions & 4 deletions js2-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -2565,7 +2565,10 @@ so many of its properties will be nil.
(js2-print-named-imports exports-list)))
(unless (or (and default (not (js2-assign-node-p default)))
(and declaration (or (js2-function-node-p declaration)
(js2-class-node-p declaration))))
(js2-class-node-p declaration)
(js2-type-alias-node-p declaration)
(js2-opaque-type-alias-node-p declaration)
(js2-interface-node-p declaration))))
(insert ";\n"))))

(cl-defstruct (js2-while-node
Expand Down Expand Up @@ -9907,8 +9910,7 @@ invalid export statements."
(= (js2-peek-token) js2-LC)) ; match 'export {'
(setq type-export (js2-parse-export (js2-current-token) beg)))
(t ; match 'export type a', was a type alias decl
;; TODO export type alias decls
nil)))
(setq declaration (js2-parse-type-alias)))))
((js2-match-token js2-MUL)
(setq from-clause (js2-parse-from-clause))
(when from-clause
Expand Down Expand Up @@ -9942,6 +9944,10 @@ invalid export statements."
(setq declaration (js2-parse-variables (js2-current-token-type) (js2-current-token-beg))))
((js2-match-token js2-CLASS)
(setq declaration (js2-parse-class-stmt)))
((js2-match-token js2-INTERFACE)
(setq declaration (js2-parse-interface)))
((js2-match-token js2-OPAQUE)
(setq declaration (js2-parse-opaque-type-alias)))
((js2-match-token js2-NAME)
(setq declaration
(if (js2-match-async-function)
Expand Down Expand Up @@ -12547,7 +12553,10 @@ And, if CHECK-ACTIVATION-P is non-nil, use the value of TOKEN."
(defun js2-parse-object-type (begin-token &optional decl-p)
"Parse object type, e.g. { a: b }"
(let ((pos (js2-current-token-beg))
(end-token (if (and (= begin-token js2-LCB) (not decl-p)) js2-RCB js2-RC)))
(end-token (if (and (= begin-token js2-LCB)
(not decl-p))
js2-RCB
js2-RC)))
(if (js2-match-token end-token) ; match {}
(make-js2-object-type-node :pos pos
:len (- (js2-current-token-end) pos)
Expand Down
18 changes: 10 additions & 8 deletions tests/flow.el
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,8 @@ the test."
"var a: |;"
:syntax-error "|")

;;; Declatation, Statements, Expressions

;; Variables

(js2-deftest-parse variable-with-type
Expand Down Expand Up @@ -948,8 +950,8 @@ the test."
(js2-deftest-parse interface-with-type-params
"interface a<b> {}")

;; (js2-deftest-parse interface-with-export
;; "export interface a<b> {\n}")
(js2-deftest-parse interface-with-export
"export interface a<b> {}")

;; Type aliases

Expand All @@ -959,8 +961,8 @@ the test."
(js2-deftest-parse type-alias-with-type-params
"type a<b> = c;")

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

;; Opaque type aliases

Expand All @@ -978,11 +980,11 @@ the test."
:syntax-error ";"
:errors-count 2)

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

;; (js2-deftest-parse opaque-type-alias-subtype-with-export
;; "export opaque type a<b>: c = d;")
(js2-deftest-parse opaque-type-alias-subtype-with-export
"export opaque type a<b>: c = d;")

;; Type casing expr
;; Declares
Expand Down

0 comments on commit 7237d04

Please sign in to comment.