Skip to content

Commit

Permalink
Introduced default type parameters to simplify reviewer and editor su…
Browse files Browse the repository at this point in the history
…pport
  • Loading branch information
Rod Johnson committed Oct 11, 2017
1 parent 06a4673 commit ba1117b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/operations/edit/projectEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { RepoId } from "../common/RepoId";
/**
* Modifies the given project, returning information about the modification.
*/
export type ProjectEditor<ER extends EditResult> =
export type ProjectEditor<ER extends EditResult = EditResult> =
(id: RepoId, p: Project, context: HandlerContext) => Promise<ER>;

/**
Expand Down
4 changes: 3 additions & 1 deletion src/operations/review/ReviewerCommandSupport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import { ProjectReview, ReviewResult } from "./ReviewResult";
* Support for reviewing multiple projects
* Subclasses should have @CommandHandler annotation
*/
export abstract class ReviewerCommandSupport<RR extends ReviewResult<PR>, PR extends ProjectReview>
export abstract class ReviewerCommandSupport<
RR extends ReviewResult<PR> = ReviewResult<PR>,
PR extends ProjectReview = ProjectReview>
extends LocalOrRemoteRepoOperation
implements HandleCommand {

Expand Down
2 changes: 1 addition & 1 deletion src/operations/review/projectReviewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ import { ProjectReview } from "./ReviewResult";
/**
* Function that can review a project
*/
export type ProjectReviewer<RR extends ProjectReview> =
export type ProjectReviewer<RR extends ProjectReview = ProjectReview> =
(id: RepoId, p: Project, context: HandlerContext) => Promise<RR>;
18 changes: 18 additions & 0 deletions test/operations/review/ReviewerCommandSupport.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

import "mocha";
import { HandlerContext } from "../../../src/HandlerContext";
import { ProjectReviewer } from "../../../src/operations/review/projectReviewer";
import { ReviewerCommandSupport } from "../../../src/operations/review/ReviewerCommandSupport";

describe("ReviewerCommandSupport", () => {

it("should compile", () => {
class MyReviewer extends ReviewerCommandSupport {

public projectReviewer(context: HandlerContext): ProjectReviewer {
throw new Error("I don't care if this works so long as it compiles");
}
}
});

});

0 comments on commit ba1117b

Please sign in to comment.