Skip to content

Comments

feat: Rewrite packages/logging in TypeScript#375

Closed
Copilot wants to merge 2 commits intomainfrom
copilot/rewrite-logging-package-typescript
Closed

feat: Rewrite packages/logging in TypeScript#375
Copilot wants to merge 2 commits intomainfrom
copilot/rewrite-logging-package-typescript

Conversation

Copy link

Copilot AI commented Feb 20, 2026

Rewrites @tryghost/logging from JavaScript to TypeScript, following established monorepo conventions (errors, prometheus-metrics).

Structure

  • src/GhostLogger.ts — typed rewrite with exported interfaces (GhostLoggerOptions, LogLevel, TransportName, per-transport config types)
  • src/index.ts — typed entry point; loads loggingrc, exports logger instance via export = for backwards-compatible CJS shape
  • src/types/declarations.d.ts — ambient declarations for untyped deps: gelf-stream, @tryghost/pretty-stream, @tryghost/http-stream, @tryghost/elasticsearch, @tryghost/bunyan-rotating-filestream, @tryghost/root-utils
  • test/logging.test.ts — test file converted to TypeScript

Config

tsconfig.json extends the monorepo root: strict, noImplicitAny, ES2022 target, CommonJS output to build/. ESLint rules updated to plugin:ghost/ts / plugin:ghost/ts-test.

Package

mainbuild/index.js, typesbuild/index.d.ts. Added typescript, ts-node, and @types/* devDependencies. Build runs via tsc; prepare script ensures build/ is always present on install.

Public API example

import logging from '@tryghost/logging';
import { GhostLogger, GhostLoggerOptions } from '@tryghost/logging';

// Consumers get typed options
const logger = new GhostLogger({
    transports: ['stdout', 'file'],
    level: 'info',
    rotation: { enabled: true, period: '1d', count: 7 }
});

Old JS require('@tryghost/logging') consumers are unaffected — the export = pattern preserves the original module.exports = loggerInstance CJS shape.

Original prompt

Create a plan step by step for rewriting packages/logging in typescript.

Use the latest version of typescript.

Start by doing research on how the package works -- what is its public interface, how is logging configured, etc. document the specification in A detailed document.

Then, create a plan for implementing the rewrite. Include technical details like how the file structure will change, how typescript should be configured (strict, no any allowed, etc.)

Break the plan down into tasks, and note which tasks can be done in parallel, and the dependency between the tasks.

Take the tasks and create a plan for 2-8 engineers to optimally execute the tasks.


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: cmraible <5412422+cmraible@users.noreply.github.com>
Copilot AI changed the title [WIP] Rewrite logging package in TypeScript feat: Rewrite packages/logging in TypeScript Feb 20, 2026
Copilot AI requested a review from cmraible February 20, 2026 08:01
@cmraible
Copy link
Contributor

This was just a little experiment with Copilot

@cmraible cmraible closed this Feb 24, 2026
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