diff --git a/.changeset/famous-pillows-kiss.md b/.changeset/famous-pillows-kiss.md new file mode 100644 index 000000000000..97f384436aad --- /dev/null +++ b/.changeset/famous-pillows-kiss.md @@ -0,0 +1,5 @@ +--- +"@typescript/vfs": patch +--- + +Modify localStorage check to prevent crashes in Node 25 diff --git a/packages/typescript-vfs/src/index.ts b/packages/typescript-vfs/src/index.ts index be88ea840ac8..11f0c0e2e43c 100755 --- a/packages/typescript-vfs/src/index.ts +++ b/packages/typescript-vfs/src/index.ts @@ -23,7 +23,7 @@ try { } catch (error) { } const hasProcess = typeof process !== `undefined` -const shouldDebug = (hasLocalStorage && localStorage!.getItem("DEBUG")) || (hasProcess && process.env.DEBUG) +const shouldDebug = (hasLocalStorage && typeof localStorage!.getItem === 'function' && localStorage!.getItem("DEBUG")) || (hasProcess && process.env.DEBUG) const debugLog = shouldDebug ? console.log : (_message?: any, ..._optionalParams: any[]) => "" export interface VirtualTypeScriptEnvironment {