feat: export TypeScript types for better DX#219
Conversation
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)
|
Someone is attempting to deploy a commit to the wowcats Team on Vercel. A member of the Team first needs to authorize it. |
thejesh23
left a comment
There was a problem hiding this comment.
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.
Summary
Export TypeScript types so integrators get proper autocomplete and type checking.
Before
After
Exported Types
Main configuration:
IInit- Main initialization optionsFormProps- Swap form configurationJupiterPlugin- Window.Jupiter interfaceDisplay options:
WidgetPosition- Widget placement optionsWidgetSize- Widget size optionsSwapMode- ExactIn/ExactOut/ExactInOrOutDEFAULT_EXPLORER- Explorer optionsCallback types:
IForm- Form state passed to onFormUpdateQuoteResponse- Quote data in callbacksSwapResult- Result passed to onSuccessSwappingStatus- Transaction statusScreens- Screen state for onScreenUpdateImpact
Better DX for TypeScript users with zero runtime changes.