Skip to content

Commit 85cc26c

Browse files
committed
fix: provide obj info to function
1 parent eb03ba0 commit 85cc26c

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

src/util/codegen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export const call =
88

99
export const arrow =
1010
(params: Expression[], statements: Statement[]) =>
11-
`(${params.join(",")}) => {${statements.join("; ")}}` as Expression
11+
`(${params.join(", ")}) => {${statements.join("; ")}}` as Expression

src/util/projectToJs.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,15 @@ export const getFunctionArgs =
9696
export const functionToArrow =
9797
({params, statements}: Block) =>
9898
cg.arrow(
99-
getFunctionArgs(params[0] as Block),
99+
[
100+
...getFunctionArgs(params[0] as Block),
101+
"obj" as Expression,
102+
],
100103
statements[0].map(
101104
blockToExpression
102105
)
103106
)
104-
.replaceAll(`, "$obj$"`, "")
105-
.replaceAll(`"$obj$"`, "") as Expression
107+
.replaceAll(`"$obj$"`, "obj") as Expression
106108

107109
export const blockGroupToArrow =
108110
(blockGroup: Block[]) =>

test/proj2.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)