microsoft / microsoft/TypeChat

Give access to `data` if `result.success === false`

Open
#116 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
8.7k
Forks
414
Avg merge
3h 8m
Merged PRs (30d)
3

Description

/**
 * An object representing a successful operation with a result of type `T`.
 */
export type Success<T> = {
    success: true;
    data: T;
};
/**
 * An object representing an operation that failed for the reason given in `message`.
 */
export type Error = {
    success: false;
    message: string;
};
/**
 * An object representing a successful or failed operation of type `T`.
 */
export type Result<T> = Success<T> | Error;
/**
 * Returns a `Success<T>` object.
 * @param data The value for the `data` property of the result.
 * @returns A `Success<T>` object.
 */
export declare function success<T>(data: T): Success<T>;
/**
 * Returns an `Error` object.
 * @param message The value for the `message` property of the result.
 * @returns An `Error` object.
 */
export declare function error(message: string): Error;
/**
 * Obtains the value associated with a successful `Result<T>` or throws an exception if
 * the result is an error.
 * @param result The `Result<T>` from which to obtain the `data` property.
 * @returns The value of the `data` property.
 */
export declare function getData<T>(result: Result<T>): T;

It would be useful to get access to data typed as unknown even if result.success === false. This would enable you to use the data and create your own repair pipeline.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Result, Error, and getData declarations shown in the issue, then locate their source and any related type tests. Done means callers can access data as unknown when success is false while existing successful-result behavior remains intact; verify the relevant type behavior in the project’s tests if available.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.