Skip to content

Commit 4ec0db4

Browse files
committed
Simplify fix for jashkenas#4464
This uses more of the existing machinery for moving class body expressions into the initializer.
1 parent becdf50 commit 4ec0db4

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

lib/coffeescript/nodes.js

+3-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/nodes.coffee

+3-4
Original file line numberDiff line numberDiff line change
@@ -1760,11 +1760,10 @@ exports.Class = class Class extends Base
17601760

17611761

17621762
# Add an expression to the class initializer
1763-
#
1764-
# NOTE Currently, only methods and static methods are valid in ES class initializers.
1765-
# When additional expressions become valid, this method should be updated to handle them.
17661763
addInitializerExpression: (node) ->
1767-
if @validInitializerMethod node
1764+
if node.unwrapAll() instanceof PassthroughLiteral
1765+
node
1766+
else if @validInitializerMethod node
17681767
@addInitializerMethod node
17691768
else
17701769
null

0 commit comments

Comments
 (0)