Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

Description

Fixes a bug in the TypeScript SDK generator where pagination endpoints with optional response containers would generate invalid type signatures like undefined.List.Item.

Link to Devin run: https://app.devin.ai/sessions/64d3e6a952544a91a61aa47698a37441
Requested by: [email protected] (@tjb9dc)

Problem

When generating pagination return types for endpoints where the items array is nested under an optional property (e.g., response.data?.list where data is optional), the generator would produce invalid TypeScript:

// Before fix - INVALID TypeScript
Promise<core.Page<Agora.ListTelephonyResponse.Data | undefined.List.Item, ...>>

The issue occurred because getReferenceToResponsePropertyType() was converting a union type node like ListTelephonyResponse.Data | undefined to a string, then appending .List.Item, resulting in undefined.List.Item.

Changes Made

  • Added import for removeUndefinedAndNullFromTypeNode utility
  • Modified TypeContextImpl.getReferenceToResponsePropertyType() to strip undefined and null from type nodes before converting to strings for inline property type name construction
  • This ensures dotted type paths like ListTelephonyResponse.Data.List.Item are built correctly without union types in the middle

Testing

⚠️ Important for reviewers:

  • This fix has NOT been tested against actual SDK generation yet
  • No regression test fixture was added
  • Seed tests should be run to verify the fix works and doesn't break existing functionality

Recommended review steps:

  1. Verify the fix resolves the issue in the agoraio-ts-sdk example
  2. Run TypeScript SDK seed tests, especially pagination fixtures
  3. Check if Page._getReferenceToType has similar issues
  4. Consider adding a seed fixture for pagination with optional containers

Risk Assessment

  • Scope: This change affects all inline property type resolution, not just pagination
  • Confidence: High that this fixes the reported bug, but untested against actual generation
  • Side effects: Possible edge cases where removing undefined/null from type name strings could cause issues

@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants