Skip to content

[AI Improvement] [Task] Remove dead EmulatorLog.waitForLog/toPrettyString and unused ImportExportEmulators type from src/emulator/types.ts - #11501

Open
joehan wants to merge 13 commits into
mainfrom
ai-improve-585186590-task-remove-dead-emulatorlog-waitfo
Open

joehan wants to merge 13 commits into
mainfrom
ai-improve-585186590-task-remove-dead-emulatorlog-waitfo

Conversation

@joehan

@joehan joehan commented Nov 12, 2026

Copy link
Copy Markdown
Member

Description

Resolves Buganizer b/585186590

Removes unused declarations and dead code from src/emulator/types.ts:

  • Removes the unused ImportExportEmulators type alias while retaining IMPORT_EXPORT_EMULATORS.
  • Removes EmulatorLog.waitForLog and the EventEmitter import from "events" that was only used by waitForLog.
  • Removes EmulatorLog.toPrettyString().
  • Simplifies EmulatorLog.toString() / EmulatorLog.toStringCore() to drop the now-unused pretty parameter and extra undefined, 0 arguments to JSON.stringify, producing identical compact JSON output.

No CHANGELOG.md entry is included as this is internal dead-code removal with no user-facing changes.

Scenarios Tested

  • git grep -n -w -e waitForLog -e toPrettyString -e ImportExportEmulators (0 matches)
  • node_modules/.bin/prettier --check src/emulator/types.ts (passed)
  • npm run build (passed)
  • npm run test:compile (passed)
  • npx tsc --noEmit -p scripts/emulator-tests/tsconfig.dev.json (passed)
  • npm run lint:quiet (passed)
  • npx mocha 'src/emulator/**/*.spec.ts' --forbid-only (633 passing, 1 pending)
  • npm run mocha -- --forbid-only (5978 passing, 11 pending)

Sample Commands

N/A

@joehan joehan self-assigned this Nov 12, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request simplifies src/emulator/types.ts by removing unused imports, types, and methods, including EventEmitter, ImportExportEmulators, EmulatorLog.waitForLog, and EmulatorLog.toPrettyString. It also refactors EmulatorLog.toString to always return a minified JSON string. The feedback suggests further simplifying the class by inlining the JSON serialization logic directly into toString and removing the now-redundant private toStringCore method.

Comment thread src/emulator/types.ts
Comment on lines 301 to 303
toString(): string {
return this.toStringCore(false);
}

toPrettyString(): string {
return this.toStringCore(true);
return this.toStringCore();
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Since toPrettyString has been removed, toStringCore is now only called once by toString. We can simplify the class and reduce indirection by inlining the JSON serialization logic directly into toString and removing the private toStringCore method entirely.

Suggested change
toString(): string {
return this.toStringCore(false);
}
toPrettyString(): string {
return this.toStringCore(true);
return this.toStringCore();
}
toString(): string {
return JSON.stringify({
timestamp: this.timestamp,
level: this.level,
text: this.text,
data: this.data,
type: this.type,
});
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inlined JSON.stringify(...) directly into EmulatorLog.toString() in commit f554a5c.

Comment thread src/emulator/types.ts Outdated
Comment on lines 349 to 357
private toStringCore(): string {
return JSON.stringify({
timestamp: this.timestamp,
level: this.level,
text: this.text,
data: this.data,
type: this.type,
});
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This private helper method is no longer needed if its logic is inlined directly into toString(). Please remove it to keep the codebase clean and maintainable.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the private toStringCore() helper in commit f554a5c.

@joehan
joehan marked this pull request as ready for review November 13, 2026 19:27

@shettyvarun268 shettyvarun268 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved with a +1 to both gemini bot comments

@joehan

joehan commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

@shettyvarun268 +1'd both gemini-code-assist suggestions above, so let's apply them: inline the JSON.stringify(...) from toStringCore() into EmulatorLog.toString(), and remove the private toStringCore() helper.

@joehan

joehan commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Addressed the review feedback in commit f554a5c:

  • Inlined the JSON.stringify(...) call directly into EmulatorLog.toString() in src/emulator/types.ts.
  • Removed the private toStringCore() helper.

Verified locally with prettier --check, npm run build, npm run test:compile, tsc --noEmit -p scripts/emulator-tests/tsconfig.dev.json, npm run lint:quiet, npx mocha "src/emulator/**/*.spec.ts" --forbid-only (643 passing, 1 pending), and npm run mocha -- --forbid-only (6131 passing, 11 pending).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants