Skip to content

Converted @tryghost/tpl to TypeScript#720

Open
EvanHahn wants to merge 1 commit into
mainfrom
convert-tpl-to-typescript
Open

Converted @tryghost/tpl to TypeScript#720
EvanHahn wants to merge 1 commit into
mainfrom
convert-tpl-to-typescript

Conversation

@EvanHahn

Copy link
Copy Markdown
Contributor

no ref

This converts @tryghost/tpl to TypeScript, and exports type definitions with the package. This should be backwards-compatible.

@coderabbitai

This comment was marked as low quality.

@EvanHahn EvanHahn force-pushed the convert-tpl-to-typescript branch from a548827 to 6a562dd Compare June 10, 2026 19:16
@codecov-commenter

codecov-commenter commented Jun 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.04%. Comparing base (9773682) to head (d0efb99).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #720      +/-   ##
==========================================
- Coverage   98.05%   98.04%   -0.01%     
==========================================
  Files          85       84       -1     
  Lines        2770     2759      -11     
  Branches      508      506       -2     
==========================================
- Hits         2716     2705      -11     
  Misses         12       12              
  Partials       42       42              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR converts the @tryghost/tpl workspace package from JavaScript to TypeScript and starts publishing generated .d.ts type definitions alongside the compiled JavaScript, while aiming to preserve the existing CommonJS consumption pattern.

Changes:

  • Add TypeScript project configuration for packages/tpl (build + test typecheck).
  • Replace the implementation entrypoints with TypeScript sources and emit .js/.d.ts via tsc.
  • Update package metadata/scripts to build before tests and publish type declarations.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pnpm-lock.yaml Updates the lockfile for packages/tpl dev dependency changes (TypeScript + Node types).
packages/tpl/vitest.config.ts Adds per-package Vitest config merged from the repo root configuration.
packages/tpl/tsconfig.test.json Adds a test-specific TS config enabling Node + Vitest global typings.
packages/tpl/tsconfig.json Adds the package TS build configuration extending the shared packages/tsconfig.json.
packages/tpl/test/tpl.test.ts Migrates tests from CommonJS require to ES imports and minor const cleanups.
packages/tpl/package.json Publishes generated .d.ts, adds build/prepare scripts, and adds TS-related dev deps.
packages/tpl/lib/tpl.ts Converts implementation to TypeScript and switches to export = for CJS compatibility.
packages/tpl/index.ts Adds TS entrypoint re-exporting the implementation with export =.
packages/tpl/index.js Removes the committed JS entrypoint (now generated by tsc).
packages/tpl/.gitignore Ignores generated build artifacts (.js, .d.ts, maps) in the package folder.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (1)

packages/tpl/lib/tpl.ts:10

  • The exported tpl type currently restricts data values to string, but in-repo callers pass non-string values (e.g. numeric {max} in packages/validator/lib/validate.js). This makes the new published typings unnecessarily breaking for TypeScript consumers. Widening the value type and explicitly stringifying replacements keeps runtime behavior the same while improving the public typings.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@EvanHahn EvanHahn requested a review from 9larsons June 10, 2026 19:25
@EvanHahn

Copy link
Copy Markdown
Contributor Author

I requested a review from Copilot because CodeRabbit didn't work (hit a usage limit).

no ref

This converts `@tryghost/tpl` to TypeScript, and exports type
definitions with the package. This should be backwards-compatible.
@EvanHahn EvanHahn force-pushed the convert-tpl-to-typescript branch from 6a562dd to d0efb99 Compare June 10, 2026 19:27
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.

3 participants