Commit 31ff604
fix: Comprehensive TypeScript definitions audit and fixes (#534)
## Summary
This PR addresses multiple critical issues with TypeScript definitions
found during a comprehensive audit of the codebase.
> NOTE: AI was used to generate these changes which would have been
difficult to identify by hand.
Closes #438 (partially)
Closes #515
## Fixes
- Fixes #515 - ReferralCustomer type export issue
- Property now correctly exported as `ReferralCustomer` (not `Referral`)
to match JavaScript implementation
- Added missing `api_keys` field to Referral interface
## Changes
### Critical Issues Fixed
#### 1. Duplicate Rate Definitions
- **Problem**: Two separate IRate interfaces in `types/Rate/Rate.d.ts`
and `types/Shipment/Rate.d.ts`
- **Fix**: Consolidated into single canonical definition, removed
duplicate
- **Files**: Deleted `types/Shipment/Rate.d.ts`, updated
`types/Shipment/index.d.ts` to re-export from `../Rate`
#### 2. Missing Exports
Added missing exports to `types/index.d.ts`:
- Referral
- Claim
- CustomerPortal
- Embeddable
- SmartRate
- Luma
#### 3. Missing Service Definitions
Added missing services to EasyPost client (`types/EasyPost.d.ts`):
- Luma
- Claim
- CustomerPortal (as CustomerPortalAccountLink)
- Embeddable (as EmbeddablesSession)
- SmartRate
- ReferralCustomer (as Referral) ← **Fixes #515**
#### 4. Missing Type Definitions
- **Luma**: Created complete type definitions based on
`src/services/luma_service.js`
- `types/Luma/Luma.d.ts`
- `types/Luma/index.d.ts`
- **SmartRate**: Created missing `types/SmartRate/index.d.ts`
- **TaxIdentifier**: Created `types/Shipment/TaxIdentifier.d.ts` for
embedded tax identifier objects
### High Priority Fixes
#### 5. Interface/Class Property Mismatches
- **Pickup.instructions**: Made class property optional nullable to
match interface
- **Order**: Fixed `return_address`, `buyer_address`, `is_return` to be
optional nullable
- **User.reference**: Added missing field to IUser interface
#### 6. Typos and Inconsistencies
- **Options.d.ts**: Fixed typo `pickup_man_datetime` →
`pickup_max_datetime`
- **ScanForm.d.ts**: Standardized `getNextPage()` return type to use
`scan_forms`
- **Referral.d.ts**: Standardized `getNextPage()` return type to use
`referral_customers`
## Testing
- ✅ Build successful: `npm run build`
- ✅ All tests passing: 173 tests across 34 test files
- ✅ All new type files created correctly
- ✅ Duplicate files removed successfully
## Files Changed
**Modified (12)**:
- types/EasyPost.d.ts
- types/Order/Order.d.ts
- types/Pickup/Pickup.d.ts
- types/Referral/Referral.d.ts
- types/ScanForm/ScanForm.d.ts
- types/Shipment/Options/Options.d.ts
- types/Shipment/Shipment.d.ts
- types/Shipment/ShipmentCreateParameters.d.ts
- types/Shipment/index.d.ts
- types/User/User.d.ts
- types/index.d.ts
**Created (5)**:
- types/Luma/Luma.d.ts
- types/Luma/index.d.ts
- types/SmartRate/index.d.ts
- types/Shipment/TaxIdentifier.d.ts
**Deleted (1)**:
- types/Shipment/Rate.d.ts
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>1 parent 6d434a8 commit 31ff604
17 files changed
Lines changed: 118 additions & 88 deletions
File tree
- types
- Luma
- Order
- Pickup
- Referral
- ScanForm
- Shipment
- Options
- SmartRate
- User
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
7 | 9 | | |
| 10 | + | |
8 | 11 | | |
9 | 12 | | |
10 | 13 | | |
11 | 14 | | |
| 15 | + | |
12 | 16 | | |
13 | 17 | | |
14 | 18 | | |
| |||
19 | 23 | | |
20 | 24 | | |
21 | 25 | | |
| 26 | + | |
22 | 27 | | |
23 | 28 | | |
24 | 29 | | |
| |||
77 | 82 | | |
78 | 83 | | |
79 | 84 | | |
| 85 | + | |
| 86 | + | |
80 | 87 | | |
81 | 88 | | |
| 89 | + | |
82 | 90 | | |
83 | 91 | | |
84 | 92 | | |
85 | 93 | | |
| 94 | + | |
86 | 95 | | |
87 | 96 | | |
88 | 97 | | |
89 | 98 | | |
90 | 99 | | |
91 | | - | |
| 100 | + | |
92 | 101 | | |
93 | 102 | | |
94 | 103 | | |
95 | 104 | | |
| 105 | + | |
96 | 106 | | |
97 | 107 | | |
98 | 108 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
| 70 | + | |
71 | 71 | | |
72 | 72 | | |
73 | | - | |
74 | | - | |
| 73 | + | |
| 74 | + | |
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | | - | |
| 78 | + | |
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | | - | |
| 104 | + | |
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
| |||
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
11 | 19 | | |
12 | 20 | | |
13 | 21 | | |
| |||
26 | 34 | | |
27 | 35 | | |
28 | 36 | | |
| 37 | + | |
29 | 38 | | |
30 | 39 | | |
31 | 40 | | |
| |||
111 | 120 | | |
112 | 121 | | |
113 | 122 | | |
114 | | - | |
| 123 | + | |
115 | 124 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | | - | |
| 125 | + | |
126 | 126 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
275 | 275 | | |
276 | 276 | | |
277 | 277 | | |
278 | | - | |
| 278 | + | |
279 | 279 | | |
280 | 280 | | |
281 | 281 | | |
| |||
This file was deleted.
0 commit comments