Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use debug package for debug logging #3167

Open
wants to merge 6 commits into
base: v2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/ts-twoslasher/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"lint": "dts lint"
},
"devDependencies": {
"@types/debug": "^4.1.12",
"@types/jest": "^29.5.12",
"@types/prettier": "^1.19.0",
"dts-cli": "^2.0.5",
Expand All @@ -53,7 +54,7 @@
},
"dependencies": {
"@typescript/vfs": "workspace:*",
"debug": "^4.1.1",
"debug": "^4.3.4",
"lz-string": "^1.5.0"
},
"peerDependencies": {
Expand Down
11 changes: 3 additions & 8 deletions packages/ts-twoslasher/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
let hasLocalStorage = false
try {
hasLocalStorage = typeof localStorage !== `undefined`
} catch (error) { }
const hasProcess = typeof process !== `undefined`
const shouldDebug = (hasLocalStorage && localStorage.getItem("DEBUG")) || (hasProcess && process.env.DEBUG)

type LZ = typeof import("lz-string")
type TS = typeof import("typescript")
type CompilerOptions = import("typescript").CompilerOptions
Expand All @@ -15,7 +8,9 @@ import { validateInput, validateCodeForErrors } from "./validation"

import { createSystem, createVirtualTypeScriptEnvironment, createFSBackedSystem } from "@typescript/vfs"

const log = shouldDebug ? console.log : (_message?: any, ..._optionalParams: any[]) => ""
import Debug from 'debug'

const log = Debug("typescript:vfs")
KermanX marked this conversation as resolved.
Show resolved Hide resolved

// Hacking in some internal stuff
declare module "typescript" {
Expand Down
3 changes: 2 additions & 1 deletion packages/typescript-vfs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@
"typescript": false
},
"dependencies": {
"debug": "^4.1.1"
"debug": "^4.3.4"
},
"devDependencies": {
"@types/debug": "^4.1.12",
"@types/jest": "^29.5.12",
"babel-jest": "^29.7.0",
"cpy-cli": "^3.1.1",
Expand Down
11 changes: 3 additions & 8 deletions packages/typescript-vfs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,9 @@ interface LocalStorageLike {
declare var localStorage: LocalStorageLike | undefined;
declare var fetch: FetchLike | undefined;

let hasLocalStorage = false
try {
hasLocalStorage = typeof localStorage !== `undefined`
} catch (error) { }

const hasProcess = typeof process !== `undefined`
const shouldDebug = (hasLocalStorage && localStorage!.getItem("DEBUG")) || (hasProcess && process.env.DEBUG)
const debugLog = shouldDebug ? console.log : (_message?: any, ..._optionalParams: any[]) => ""
import Debug from 'debug'

const debugLog = Debug("typescript:vfs")

export interface VirtualTypeScriptEnvironment {
sys: System
Expand Down
22 changes: 20 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.