Skip to content

feat: export TypeScript types for better DX#219

Open
happy-edge wants to merge 1 commit into
jup-ag:mainfrom
happy-edge:feat/typescript-exports
Open

feat: export TypeScript types for better DX#219
happy-edge wants to merge 1 commit into
jup-ag:mainfrom
happy-edge:feat/typescript-exports

Conversation

@happy-edge

Copy link
Copy Markdown

Summary

Export TypeScript types so integrators get proper autocomplete and type checking.

Before

import { init } from '@jup-ag/plugin';
// ❌ No type exports - integrators have to define their own types or use 'any'

After

import { init } from '@jup-ag/plugin';
import type { IInit, FormProps, QuoteResponse, SwapResult } from '@jup-ag/plugin';

// ✅ Full autocomplete and type checking
const config: IInit = {
  formProps: { /* autocomplete works */ },
  onSuccess: ({ txid, swapResult }) => { /* typed! */ }
};

Exported Types

Main configuration:

  • IInit - Main initialization options
  • FormProps - Swap form configuration
  • JupiterPlugin - Window.Jupiter interface

Display options:

  • WidgetPosition - Widget placement options
  • WidgetSize - Widget size options
  • SwapMode - ExactIn/ExactOut/ExactInOrOut
  • DEFAULT_EXPLORER - Explorer options

Callback types:

  • IForm - Form state passed to onFormUpdate
  • QuoteResponse - Quote data in callbacks
  • SwapResult - Result passed to onSuccess
  • SwappingStatus - Transaction status
  • Screens - Screen state for onScreenUpdate

Impact

Better DX for TypeScript users with zero runtime changes.

Integrators using TypeScript can now import types directly:

```typescript
import type {
  IInit,
  FormProps,
  QuoteResponse,
  SwapResult
} from '@jup-ag/plugin';
```

Exported types:
- IInit, FormProps, JupiterPlugin (main config)
- WidgetPosition, WidgetSize, SwapMode, DEFAULT_EXPLORER (options)
- IForm, QuoteResponse, SwapResult, SwappingStatus, Screens (callbacks)
@vercel

vercel Bot commented Feb 6, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the wowcats Team on Vercel.

A member of the Team first needs to authorize it.

@thejesh23 thejesh23 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.

Good DX improvement, but one thing to verify before merge:

DEFAULT_EXPLORER is in the export type { ... } block, but the SCREAMING_SNAKE_CASE name strongly suggests it's a runtime constant, not a type. A type-only export erases at runtime, so import { DEFAULT_EXPLORER } from '@jup-ag/plugin' would resolve to undefined. If it's a const, it needs a regular export; if it's actually a type alias, the name is misleading and worth renaming.

Same caveat applies to SwapMode, WidgetPosition, WidgetSize if any of them are TS enums rather than string-literal unions — enums need value re-export to be usable as SwapMode.ExactIn at runtime.

Easy way to confirm: check src/types/index.d.ts for each — if it's export const / export enum, move it out of the export type block.

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