Skip to content

v2: Refactor task-related properties and improve type definitions #1275

@felixweinberger

Description

@felixweinberger

Summary

Refactoring opportunities for the v2 implementation related to task properties and TypeScript type definitions.

Motivation and Context

The current implementation has some patterns that could be improved for better code organization and type safety.

Proposed Changes

1. Group task-related properties

Currently there are multiple taskX variables at the same level:

taskId?: string;
taskStore?: RequestTaskStore;
taskRequestedTtl?: number | null;

Consider grouping these under a single task object:

task?: {
    id: string;
    store: RequestTaskStore;
    requestedTtl: number | null;
};

This provides better organization and makes it clearer these properties are related.

2. Distinguish between optional properties and undefined values

In TypeScript:

// Property may be omitted entirely
{ prop?: string; }

// Property must be present, but can be undefined
{ prop: string | undefined; }

These have different semantics:

  • prop?: string - the property may not exist at all
  • prop: string | undefined - the property always exists but may be undefined

We should audit the codebase and use the appropriate pattern based on actual intent. This affects:

  • API contracts (what callers must provide)
  • Serialization behavior (omitted vs explicit undefined)
  • Type narrowing (in checks vs value checks)

Additional context

Low priority - should be addressed if time permits during v2 development.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementRequest for a new feature that's not currently supportedv2Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixes

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions