Skip to content

Add TypeScript declarations for admin-api #586

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Josejj10
Copy link

@Josejj10 Josejj10 commented Aug 8, 2025

Summary

Add first-party TypeScript declarations for @tryghost/admin-api and type tests.

Checklist

  • There’s a clear use-case for this code change
  • Commit message has a short title & references relevant issues
  • The build will pass (run yarn test and yarn lint)

Changes

  • Add packages/admin-api/index.d.ts covering API resources: posts, pages, tags, members, users, newsletters, webhooks, uploads, config, site, themes.
  • Expose types via types: "index.d.ts" and include in files in packages/admin-api/package.json.
  • Add type tests under packages/admin-api/test/types:
    • tsconfig.json (self-contained)
    • types.test.ts using inline generic assertions so tsc enforces types without extra libs.
  • Add test:types script and wire it in CI if desired (currently separate).

Usage example

import GhostAdminAPI = require('@tryghost/admin-api');

const api = new GhostAdminAPI({
  url: <url>,
  key: <key>,
  version: 'v5.0',
});


const posts = await api.posts.browse({ limit:10, page:1 })

Screenshots

image image

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.

1 participant