mirror of
https://github.com/github/codeql-action.git
synced 2026-04-30 02:40:12 +00:00
Merge pull request #3506 from github/henrymercer/result-better-inference
Improve type inference of `Result<T, E>`
This commit is contained in:
Generated
+23
-21
@@ -103609,30 +103609,32 @@ function joinAtMost(array, separator, limit) {
|
||||
}
|
||||
return array.join(separator);
|
||||
}
|
||||
var Result = class _Result {
|
||||
constructor(_ok, value) {
|
||||
this._ok = _ok;
|
||||
var Success = class {
|
||||
constructor(value) {
|
||||
this.value = value;
|
||||
}
|
||||
/** Creates a success result. */
|
||||
static success(value) {
|
||||
return new _Result(true, value);
|
||||
}
|
||||
/** Creates a failure result. */
|
||||
static failure(value) {
|
||||
return new _Result(false, value);
|
||||
}
|
||||
/** Whether this result represents a success. */
|
||||
isSuccess() {
|
||||
return this._ok;
|
||||
return true;
|
||||
}
|
||||
/** Whether this result represents a failure. */
|
||||
isFailure() {
|
||||
return !this._ok;
|
||||
return false;
|
||||
}
|
||||
orElse(_defaultValue) {
|
||||
return this.value;
|
||||
}
|
||||
};
|
||||
var Failure = class {
|
||||
constructor(value) {
|
||||
this.value = value;
|
||||
}
|
||||
isSuccess() {
|
||||
return false;
|
||||
}
|
||||
isFailure() {
|
||||
return true;
|
||||
}
|
||||
/** Get the value if this is a success, or return the default value if this is a failure. */
|
||||
orElse(defaultValue) {
|
||||
return this.isSuccess() ? this.value : defaultValue;
|
||||
return defaultValue;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -109782,23 +109784,23 @@ async function loadRepositoryProperties(repositoryNwo, gitHubVersion, features,
|
||||
logger.debug(
|
||||
"Skipping loading repository properties because the repository is owned by a user and therefore cannot have repository properties."
|
||||
);
|
||||
return Result.success({});
|
||||
return new Success({});
|
||||
}
|
||||
if (!await features.getValue("use_repository_properties_v2" /* UseRepositoryProperties */)) {
|
||||
logger.debug(
|
||||
"Skipping loading repository properties because the UseRepositoryProperties feature flag is disabled."
|
||||
);
|
||||
return Result.success({});
|
||||
return new Success({});
|
||||
}
|
||||
try {
|
||||
return Result.success(
|
||||
return new Success(
|
||||
await loadPropertiesFromApi(gitHubVersion, logger, repositoryNwo)
|
||||
);
|
||||
} catch (error3) {
|
||||
logger.warning(
|
||||
`Failed to load repository properties: ${getErrorMessage(error3)}`
|
||||
);
|
||||
return Result.failure(error3);
|
||||
return new Failure(error3);
|
||||
}
|
||||
}
|
||||
function getTrapCachingEnabled() {
|
||||
|
||||
Reference in New Issue
Block a user