Skip to content

Instantly share code, notes, and snippets.

@wcjohnson
Created March 29, 2017 06:26
Show Gist options
  • Save wcjohnson/7d82583e0803b7ee40d0818aea959a1b to your computer and use it in GitHub Desktop.
Save wcjohnson/7d82583e0803b7ee40d0818aea959a1b to your computer and use it in GitHub Desktop.
> node util/test-source-maps.js "test/fixtures/arrow-methods-obj/fat-assign/actual.js"
test/fixtures/arrow-methods-obj/fat-assign/actual.js
Source code:
let o
now o = {
f() =>
this
}
Transformed code:
let o;
o = {
f() {
return this;
}
};
o.f = o.f.bind(o);
AST:
001 Program@(loc: 1:0-6:0 start: 0 end: 36)
002 VariableDeclaration@(loc: 1:0-1:5 start: 0 end: 5)
003 VariableDeclarator@(loc: 1:4-1:5 start: 4 end: 5)
004 Identifier@(loc: 1:4-1:5 start: 4 end: 5)
005 ExpressionStatement@(loc: 2:0-5:1 start: 6 end: 35)
006 AssignmentExpression@(loc: 2:0-5:1 start: 6 end: 35)
007 Identifier@(loc: 2:4-2:5 start: 10 end: 11)
008 ObjectExpression@(loc: 2:8-5:1 start: 14 end: 35)
009 ObjectMethod@(loc: 3:2-4:8 start: 18 end: 33)
010 Identifier@(loc: 3:2-3:3 start: 18 end: 19)
011 BlockStatement@(loc: 3:6-4:8 start: 22 end: 33)
012 ReturnStatement@(loc: 4:4-4:4 start: 29 end: 29)
013 ThisExpression@(loc: 4:4-4:8 start: 29 end: 33)
014 ExpressionStatement@(loc: 5:1-5:1 start: 35 end: 35)
015 AssignmentExpression@(loc: 5:1-5:1 start: 35 end: 35)
016 MemberExpression@(loc: 5:1-5:1 start: 35 end: 35)
017 Identifier@(loc: 2:4-2:5 start: 10 end: 11)
018 Identifier@(loc: 3:2-3:3 start: 18 end: 19)
019 CallExpression@(loc: 5:1-5:1 start: 35 end: 35)
020 MemberExpression@(loc: 5:1-5:1 start: 35 end: 35)
021 MemberExpression@(loc: 5:1-5:1 start: 35 end: 35)
022 Identifier@(loc: 2:4-2:5 start: 10 end: 11)
023 Identifier@(loc: 3:2-3:3 start: 18 end: 19)
024 Identifier@(loc: 5:1-5:1 start: 35 end: 35)
025 Identifier@(loc: 2:4-2:5 start: 10 end: 11)
ERRORS:
Identifier #17 @ (loc: 2:4-2:5 start: 10 end: 11): Starts before parent starts.
Identifier #18 @ (loc: 3:2-3:3 start: 18 end: 19): Starts before parent starts.
Identifier #22 @ (loc: 2:4-2:5 start: 10 end: 11): Starts before parent starts.
Identifier #23 @ (loc: 3:2-3:3 start: 18 end: 19): Starts before parent starts.
Identifier #25 @ (loc: 2:4-2:5 start: 10 end: 11): Starts before parent starts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment