diff --git a/js2-mode.el b/js2-mode.el index ea2eba52..f22c4289 100644 --- a/js2-mode.el +++ b/js2-mode.el @@ -12163,8 +12163,8 @@ When `js2-is-in-destructuring' is t, forms like {a, b, c} will be permitted." (= (js2-peek-token) js2-COLON)) (js2-node-set-prop key :type-annotation (js2-parse-type-annotation))) ;; parse type params for class method prop - (when (and class-p - (= (js2-peek-token) js2-LT)) + ;; TODO(rabbit): object method also has this feature + (when (= (js2-peek-token) js2-LT) (setq type-params (js2-parse-type-params))) (cond ;; method definition: {f() {...}} diff --git a/tests/flow.el b/tests/flow.el index c8a1997c..1cf9d023 100644 --- a/tests/flow.el +++ b/tests/flow.el @@ -1062,3 +1062,6 @@ switch (a) { case b: break; }") + +(js2-deftest-parse object-method-with-type-params + "var a = {b() {}};")