Skip to content

Commit 1843cf4

Browse files
yamcodesjakebailey
andauthored
Add proper localStorage availability checks to support Node v25 in @typescript/vfs (#3450)
Co-authored-by: Jake Bailey <5341706+jakebailey@users.noreply.github.com>
1 parent c964e94 commit 1843cf4

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

.changeset/famous-pillows-kiss.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@typescript/vfs": patch
3+
---
4+
5+
Modify localStorage check to prevent crashes in Node 25

packages/typescript-vfs/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ try {
2323
} catch (error) { }
2424

2525
const hasProcess = typeof process !== `undefined`
26-
const shouldDebug = (hasLocalStorage && localStorage!.getItem("DEBUG")) || (hasProcess && process.env.DEBUG)
26+
const shouldDebug = (hasLocalStorage && typeof localStorage!.getItem === 'function' && localStorage!.getItem("DEBUG")) || (hasProcess && process.env.DEBUG)
2727
const debugLog = shouldDebug ? console.log : (_message?: any, ..._optionalParams: any[]) => ""
2828

2929
export interface VirtualTypeScriptEnvironment {

0 commit comments

Comments
 (0)