Skip to content

Commit

Permalink
Some small cleanup tweaks (#1744)
Browse files Browse the repository at this point in the history
## Summary:
Some small changes, code pruning and typing.

Author: handeyeco

Reviewers: Myranae

Required Reviewers:

Approved By: Myranae

Checks: ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ gerald, ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x)

Pull Request URL: #1744
  • Loading branch information
handeyeco authored Oct 23, 2024
1 parent c27ee11 commit 236ef44
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 17 deletions.
6 changes: 6 additions & 0 deletions .changeset/pretty-worms-drop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@khanacademy/perseus": patch
"@khanacademy/perseus-editor": patch
---

Cleanup: remove scorePreview and refine some types
9 changes: 0 additions & 9 deletions packages/perseus-editor/src/editor-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import type {
Version,
PerseusItem,
} from "@khanacademy/perseus";
import type {KEScore} from "@khanacademy/perseus-core";

const {HUD} = components;

Expand Down Expand Up @@ -219,14 +218,6 @@ class EditorPage extends React.Component<Props, State> {
this.props.onChange(newJson);
};

scorePreview(): KEScore | null | undefined {
// Do we actually ever set this.renderer anywhere in the codebase?
if (this.renderer) {
return this.renderer.scoreInput();
}
return null;
}

render(): React.ReactNode {
let className = "framework-perseus";

Expand Down
5 changes: 0 additions & 5 deletions packages/perseus-editor/src/stateful-editor-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,6 @@ const StatefulEditorPage = createReactClass({
}
},

scorePreview: function () {
// eslint-disable-next-line react/no-string-refs
return this.refs.editor.scorePreview();
},

render: function () {
const Component = this.props.componentClass;
return <Component {...this.state} />;
Expand Down
4 changes: 2 additions & 2 deletions packages/perseus/src/renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1752,12 +1752,12 @@ class Renderer extends React.Component<Props, State> {
return combinedScore;
}

guessAndScore: () => [any, PerseusScore] = () => {
guessAndScore(): [UserInputArray, PerseusScore] {
const totalGuess = this.getUserInput();
const totalScore = this.score();

return [totalGuess, totalScore];
};
}

examples: () => ReadonlyArray<string> | null | undefined = () => {
const widgetIds = this.widgetIds;
Expand Down
4 changes: 3 additions & 1 deletion packages/perseus/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as GraphieUtil from "./util.graphie";
import type {Range} from "./perseus-types";
import type {PerseusStrings} from "./strings";
import type {PerseusScore} from "./types";
import type {UserInputArray} from "./validation.types";
import type {KEScore} from "@khanacademy/perseus-core";
import type * as React from "react";

Expand Down Expand Up @@ -275,7 +276,8 @@ export function isCorrect(score: PerseusScore): boolean {

function keScoreFromPerseusScore(
score: PerseusScore,
guess: any,
// It's weird, but this is what we're passing it
guess: UserInputArray | [UserInputArray, []],
state: any,
): KEScore {
if (score.type === "points") {
Expand Down

0 comments on commit 236ef44

Please sign in to comment.