From de6df3366977b610007e126945adf8967cce83c3 Mon Sep 17 00:00:00 2001 From: David Greenspan Date: Thu, 5 Nov 2015 23:32:14 -0800 Subject: [PATCH 1/1] Fix semicolons and scoping in exported decls In the following code, no semicolons should be considered missing, and all of A,B,C,D should be considered declared. ``` export function A() {} export class B {} export default function C() {} export default class D {} var x = [A, B, C, D]; ``` --- js2-mode.el | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/js2-mode.el b/js2-mode.el index c7af4629c..c98c00d2d 100644 --- a/js2-mode.el +++ b/js2-mode.el @@ -8842,20 +8842,30 @@ invalid export statements." (setq from-clause (js2-parse-from-clause))) (js2-unget-token)))) ((js2-match-token js2-DEFAULT) - (setq default (js2-parse-expr))) + (setq default (cond ((js2-match-token js2-CLASS) + (js2-parse-class-stmt)) + ((js2-match-token js2-FUNCTION) + (js2-parse-function-stmt)) + (t (js2-parse-expr))))) ((or (js2-match-token js2-VAR) (js2-match-token js2-CONST) (js2-match-token js2-LET)) (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-FUNCTION) + (setq declaration (js2-parse-function-stmt))) (t (setq declaration (js2-parse-expr)))) (when from-clause (push from-clause children)) (when declaration (push declaration children) - (when (not (js2-function-node-p declaration)) + (when (not (or (js2-function-node-p declaration) + (js2-class-node-p declaration))) (js2-auto-insert-semicolon declaration))) (when default (push default children) - (when (not (js2-function-node-p default)) + (when (not (or (js2-function-node-p default) + (js2-class-node-p default))) (js2-auto-insert-semicolon default))) (let ((node (make-js2-export-node :pos beg -- 2.39.2