Skip to content

Commit ffe9e69

Browse files
authored
feat(fix): refactor button instantiation into ButtonWrapper class
The problem is that `new` is being used on something that is not a constructor (likely a function component). The fix is to stop using `new` and instead use `Button` in the manner it is intended to be used. Since the next line calls `button.render()`, it looks like the code expects an instance with a `render` method; to keep behavior similar without changing `Button`'s implementation, we can create a simple wrapper class that internally calls the `Button` function. The best minimal fix inside `main.ts` is: define a small `ButtonWrapper` class that has a `render` method invoking `Button`, then instantiate that wrapper with `new ButtonWrapper()` instead of `new Button()`. This avoids changing `./button.tsx`, aligns with the intended non-constructor nature of `Button`, and preserves the existing `button.render();` call site. Concretely, in `turborepo-tests/integration/fixtures/turbo_trace/main.ts`, we will insert a `class ButtonWrapper` definition above the `const button = ...` line, change that instantiation to `new ButtonWrapper()`, and leave the `render` call as is. No new imports are required.
1 parent 59866f5 commit ffe9e69

File tree

1 file changed

+7
-1
lines changed
  • turborepo-tests/integration/fixtures/turbo_trace

1 file changed

+7
-1
lines changed
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import { Button } from "./button.tsx";
22
import foo from "./foo";
33

4-
const button = new Button();
4+
class ButtonWrapper {
5+
render() {
6+
Button();
7+
}
8+
}
9+
10+
const button = new ButtonWrapper();
511

612
button.render();
713
foo();

0 commit comments

Comments
 (0)