Skip to content

Commit 31ac9a0

Browse files
refactor: tidy up the typings of the build result in dev
In #262 some of the strict null fixes were removed to resolve a regression. This refactor re-applies these fixes in a way that avoids that problem.
1 parent 402c77d commit 31ac9a0

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

.changeset/clever-turtles-shake.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"wrangler": patch
3+
---
4+
5+
refactor: tidy up the typings of the build result in dev
6+
7+
In #262 some of the strict null fixes were removed to resolve a regression.
8+
This refactor re-applies these fixes in a way that avoids that problem.

packages/wrangler/src/dev.tsx

+2-4
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ function useEsbuild(props: {
441441
const { entry, destination, staticRoot, jsxFactory, jsxFragment } = props;
442442
const [bundle, setBundle] = useState<EsbuildBundle>();
443443
useEffect(() => {
444-
let result: esbuild.BuildResult;
444+
let result: esbuild.BuildResult | undefined;
445445
async function build() {
446446
if (!destination || !entry) return;
447447
const moduleCollector = makeModuleCollector();
@@ -508,9 +508,7 @@ function useEsbuild(props: {
508508
// so this is a no-op error handler
509509
});
510510
return () => {
511-
if (result && result.stop) {
512-
result.stop();
513-
}
511+
result?.stop?.();
514512
};
515513
}, [entry, destination, staticRoot, jsxFactory, jsxFragment]);
516514
return bundle;

0 commit comments

Comments
 (0)