Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a IZosFilesTypedResponse to offer stronger type inference for returned items #2421

Open
traeok opened this issue Jan 29, 2025 · 1 comment
Labels
enhancement New feature or request priority-low Legit issue but cosmetic or nice-to-have v4 Prospective changes for v4

Comments

@traeok
Copy link
Member

traeok commented Jan 29, 2025

Is your feature or enhancement request related to a problem or limitation? Please describe

When using z/OS File APIs, the expected properties in apiResponse are unclear. Since apiResponse is typed as any, this has also allowed inconsistencies to appear in the structure for apiResponse, even though we populate this property ourselves - see #2410

Describe your enhancement idea

By offering a IZosFilesTypedResponse, we can strongly type the apiResponse property to provide TypeScript inference for developers that process these responses.

Example:

export interface IApiResponseWithItems<T> {
    items: T[];
    // ...any remaining properties in `apiResponse` if applicable
    // support any responses that have an `items` property of type `T[]`
    [key: string]: any;
}

export interface IZosFilesTypedResponse<T> implements IZosFilesResponse {
    apiResponse?: IApiResponseWithItems<T>;
}

Describe alternatives you've considered

Users can try to interpret the response by printing it and keeping track of the keys that are returned, referencing existing code, or looking at z/OSMF API documentation. However, this opens up room for mistakes as apiResponse is any, so any property access is considered valid by TypeScript until executed at runtime:

// Invalid property, but this will compile due to the use of `any`
apiResponse.banana
@traeok traeok added enhancement New feature or request new The issue wasn't triaged yet v4 Prospective changes for v4 and removed v4 Prospective changes for v4 labels Jan 29, 2025
@github-project-automation github-project-automation bot moved this to New Issues in Zowe CLI Squad Jan 29, 2025
Copy link

Thank you for raising this enhancement request.
The community has 90 days to vote on it.
If the enhancement receives at least 5 upvotes, it is added to our development backlog.
If it receives fewer votes, the issue is closed.

@JTonda JTonda added priority-low Legit issue but cosmetic or nice-to-have and removed new The issue wasn't triaged yet labels Feb 3, 2025
@zowe-robot zowe-robot moved this from New Issues to Low Priority in Zowe CLI Squad Feb 3, 2025
@JTonda JTonda added the v4 Prospective changes for v4 label Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request priority-low Legit issue but cosmetic or nice-to-have v4 Prospective changes for v4
Projects
Status: Low Priority
Development

No branches or pull requests

2 participants