Skip to content

Commit 236ef44

Browse files
authored
Some small cleanup tweaks (#1744)
## 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
1 parent c27ee11 commit 236ef44

File tree

5 files changed

+11
-17
lines changed

5 files changed

+11
-17
lines changed

.changeset/pretty-worms-drop.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@khanacademy/perseus": patch
3+
"@khanacademy/perseus-editor": patch
4+
---
5+
6+
Cleanup: remove scorePreview and refine some types

packages/perseus-editor/src/editor-page.tsx

-9
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import type {
1717
Version,
1818
PerseusItem,
1919
} from "@khanacademy/perseus";
20-
import type {KEScore} from "@khanacademy/perseus-core";
2120

2221
const {HUD} = components;
2322

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

222-
scorePreview(): KEScore | null | undefined {
223-
// Do we actually ever set this.renderer anywhere in the codebase?
224-
if (this.renderer) {
225-
return this.renderer.scoreInput();
226-
}
227-
return null;
228-
}
229-
230221
render(): React.ReactNode {
231222
let className = "framework-perseus";
232223

packages/perseus-editor/src/stateful-editor-page.tsx

-5
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,6 @@ const StatefulEditorPage = createReactClass({
7474
}
7575
},
7676

77-
scorePreview: function () {
78-
// eslint-disable-next-line react/no-string-refs
79-
return this.refs.editor.scorePreview();
80-
},
81-
8277
render: function () {
8378
const Component = this.props.componentClass;
8479
return <Component {...this.state} />;

packages/perseus/src/renderer.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1752,12 +1752,12 @@ class Renderer extends React.Component<Props, State> {
17521752
return combinedScore;
17531753
}
17541754

1755-
guessAndScore: () => [any, PerseusScore] = () => {
1755+
guessAndScore(): [UserInputArray, PerseusScore] {
17561756
const totalGuess = this.getUserInput();
17571757
const totalScore = this.score();
17581758

17591759
return [totalGuess, totalScore];
1760-
};
1760+
}
17611761

17621762
examples: () => ReadonlyArray<string> | null | undefined = () => {
17631763
const widgetIds = this.widgetIds;

packages/perseus/src/util.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import * as GraphieUtil from "./util.graphie";
88
import type {Range} from "./perseus-types";
99
import type {PerseusStrings} from "./strings";
1010
import type {PerseusScore} from "./types";
11+
import type {UserInputArray} from "./validation.types";
1112
import type {KEScore} from "@khanacademy/perseus-core";
1213
import type * as React from "react";
1314

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

276277
function keScoreFromPerseusScore(
277278
score: PerseusScore,
278-
guess: any,
279+
// It's weird, but this is what we're passing it
280+
guess: UserInputArray | [UserInputArray, []],
279281
state: any,
280282
): KEScore {
281283
if (score.type === "points") {

0 commit comments

Comments
 (0)