Skip to content

Clean up any and as in TS files #1174

@jescalada

Description

@jescalada

Is your feature request related to a problem? Please describe.
After our TS refactors, a few places have any for wildcard types and as for casting, which we want to remove for a truly clean TS refactor.

One of the quintessential examples of this is on try-catch blocks (source: checkHiddenCommits.ts):

try {
  //...
} catch (e: any) {
  step.setError(e.message);
  throw e;
} finally {
  action.addStep(step);
}

We can replace the catch bit with the following:

catch (e: unknown) {
  if (e instanceof Error) {
    step.setError(e.message);
  }
  throw e;
}

Describe the solution you'd like
Replace all (or as many as possible) usages of any and as with properly-typed equivalents.

Additional context
Requested by @06kellyjac in #1166 (comment).

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions