Skip to content

Commit c47d3b3

Browse files
authored
Fixed a bug where sometimes call expressions would get an incorrect context parameter (#1282)
1 parent 1e81749 commit c47d3b3

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/transformation/visitors/call.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,8 @@ export const transformCallExpression: FunctionVisitor<ts.CallExpression> = (node
288288
calledExpression,
289289
node.arguments,
290290
signature,
291-
callContext
291+
// Only pass context if noImplicitSelf is not configured
292+
context.options.noImplicitSelf ? undefined : callContext
292293
);
293294
}
294295

test/unit/jsx.spec.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,18 @@ describe("jsx", () => {
288288
.addExtraFile("myJsx.ts", customJsxLib)
289289
.expectToMatchJsResult();
290290
});
291+
test("custom JSX factory with noImplicitSelf", () => {
292+
testJsx`
293+
return <a><b>c</b></a>
294+
`
295+
.setTsHeader(
296+
`function createElement(tag: string | Function, props: { [key: string]: string | boolean }, ...children: any[]) {
297+
return { tag, children };
298+
}`
299+
)
300+
.setOptions({ jsxFactory: "createElement", noImplicitSelf: true })
301+
.expectToMatchJsResult();
302+
});
291303
test("custom fragment factory", () => {
292304
testJsx`
293305
return <><b>c</b></>

0 commit comments

Comments
 (0)