diff --git a/.changeset/tough-socks-fail.md b/.changeset/tough-socks-fail.md new file mode 100644 index 0000000000..e968efc75b --- /dev/null +++ b/.changeset/tough-socks-fail.md @@ -0,0 +1,5 @@ +--- +"@khanacademy/perseus": major +--- + +Remove external-facing but unused API (getGrammarTypeForPath) diff --git a/packages/perseus/src/__tests__/renderer.test.tsx b/packages/perseus/src/__tests__/renderer.test.tsx index 9b8d0ccd3c..3ed1bb5c1a 100644 --- a/packages/perseus/src/__tests__/renderer.test.tsx +++ b/packages/perseus/src/__tests__/renderer.test.tsx @@ -1509,32 +1509,6 @@ describe("renderer", () => { }); }); - describe("getGrammarTypeForPath", () => { - it("should return undefined if matching widget doesn't implement getGrammarTypeForPath", () => { - // Arrange - const {renderer} = renderQuestion(question1); - - // Act - const grammarType = renderer.getGrammarTypeForPath(["dropdown 1"]); - - // Assert - expect(grammarType).toBeUndefined(); - }); - - it("should return widget result if matching widget implements getGrammarTypeForPath", () => { - // Arrange - const {renderer} = renderQuestion(question2); - - // Act - const grammarType = renderer.getGrammarTypeForPath([ - "input-number 1", - ]); - - // Assert - expect(grammarType).toBe("number"); - }); - }); - describe("getInputPaths", () => { it("should return all input paths for all rendererd widgets", () => { // Arrange diff --git a/packages/perseus/src/__tests__/server-item-renderer.test.tsx b/packages/perseus/src/__tests__/server-item-renderer.test.tsx index fad81ba3b0..6256ae415c 100644 --- a/packages/perseus/src/__tests__/server-item-renderer.test.tsx +++ b/packages/perseus/src/__tests__/server-item-renderer.test.tsx @@ -183,17 +183,6 @@ describe("server item renderer", () => { expect(await within(node).findAllByRole("textbox")).toHaveLength(1); }); - it("should return the grammar type for the requested focus path", () => { - // Arrange - const {renderer} = renderQuestion(itemWithInput); - - // Act - const grammarType = renderer.getGrammarTypeForPath(["input-number 1"]); - - // Assert - expect(grammarType).toBe("number"); - }); - it("should return the number of hints available", () => { // Arrange const {renderer} = renderQuestion({ diff --git a/packages/perseus/src/renderer.tsx b/packages/perseus/src/renderer.tsx index 956a36a1f0..d34a8a2b16 100644 --- a/packages/perseus/src/renderer.tsx +++ b/packages/perseus/src/renderer.tsx @@ -1503,18 +1503,6 @@ class Renderer extends React.Component { } }; - getGrammarTypeForPath: (path: FocusPath) => string | undefined = ( - path: FocusPath, - ) => { - // @ts-expect-error - TS2345 - Argument of type 'FocusPath' is not assignable to parameter of type 'List'. - const widgetId = _.first(path); - // @ts-expect-error - TS2345 - Argument of type 'FocusPath' is not assignable to parameter of type 'List'. - const interWidgetPath = _.rest(path); - - const widget = this.getWidgetInstance(widgetId); - return widget?.getGrammarTypeForPath?.(interWidgetPath); - }; - getInputPaths: () => ReadonlyArray = () => { const inputPaths: Array = []; _.each(this.widgetIds, (widgetId: string) => { diff --git a/packages/perseus/src/server-item-renderer.tsx b/packages/perseus/src/server-item-renderer.tsx index 2cc62a0dcb..fc4108a8bd 100644 --- a/packages/perseus/src/server-item-renderer.tsx +++ b/packages/perseus/src/server-item-renderer.tsx @@ -259,10 +259,6 @@ export class ServerItemRenderer return this.questionRenderer.getDOMNodeForPath(path); } - getGrammarTypeForPath(path: FocusPath): string | null | undefined { - return this.questionRenderer.getGrammarTypeForPath(path); - } - getInputPaths(): ReadonlyArray { const questionAreaInputPaths = this.questionRenderer.getInputPaths(); return questionAreaInputPaths; diff --git a/packages/perseus/src/types.ts b/packages/perseus/src/types.ts index 204b258668..7d40aa839f 100644 --- a/packages/perseus/src/types.ts +++ b/packages/perseus/src/types.ts @@ -74,8 +74,6 @@ export interface Widget { getSerializedState?: () => SerializedState; // SUSPECT, restoreSerializedState?: (props: any, callback: () => void) => any; - getGrammarTypeForPath?: (path: FocusPath) => string | undefined; - blurInputPath?: (path: FocusPath) => void; focusInputPath?: (path: FocusPath) => void; getInputPaths?: () => ReadonlyArray; diff --git a/packages/perseus/src/widgets/expression/expression.tsx b/packages/perseus/src/widgets/expression/expression.tsx index 8de7fa4a7b..84c3424e50 100644 --- a/packages/perseus/src/widgets/expression/expression.tsx +++ b/packages/perseus/src/widgets/expression/expression.tsx @@ -274,12 +274,6 @@ export class Expression return [[]]; }; - // TODO(Nicole): I believe this is going away and won't be needed anymore - getGrammarTypeForPath(inputPath: FocusPath): string { - /* c8 ignore next */ - return "expression"; - } - setInputValue(path: FocusPath, newValue: string, cb: () => void) { this.props.onChange( { diff --git a/packages/perseus/src/widgets/input-number/input-number.tsx b/packages/perseus/src/widgets/input-number/input-number.tsx index ec06ef2e61..bfb6bce367 100644 --- a/packages/perseus/src/widgets/input-number/input-number.tsx +++ b/packages/perseus/src/widgets/input-number/input-number.tsx @@ -146,13 +146,6 @@ class InputNumber extends React.Component implements Widget { return [[]]; }; - // Note: We believe that this isn't used anywhere but are leaving it during - // the initial refactor - getGrammarTypeForPath: (arg1: Path) => string = (path) => { - /* c8 ignore next */ - return "number"; - }; - setInputValue: (arg1: Path, arg2: string, arg3: () => void) => void = ( path, newValue, diff --git a/packages/perseus/src/widgets/matrix/matrix.tsx b/packages/perseus/src/widgets/matrix/matrix.tsx index e364375183..0135721ee1 100644 --- a/packages/perseus/src/widgets/matrix/matrix.tsx +++ b/packages/perseus/src/widgets/matrix/matrix.tsx @@ -167,10 +167,6 @@ class Matrix extends React.Component implements Widget { return inputPaths; }; - getGrammarTypeForPath: (arg1: any) => string = (inputPath) => { - return "number"; - }; - _handleFocus: (arg1: any, arg2: any) => void = (row, col) => { this.props.onFocus(getInputPath(row, col)); }; diff --git a/packages/perseus/src/widgets/number-line/number-line.tsx b/packages/perseus/src/widgets/number-line/number-line.tsx index 0d27e6450a..e1ea4646eb 100644 --- a/packages/perseus/src/widgets/number-line/number-line.tsx +++ b/packages/perseus/src/widgets/number-line/number-line.tsx @@ -374,12 +374,6 @@ class NumberLine extends React.Component implements Widget { return null; } - getGrammarTypeForPath(inputPath: FocusPath) { - if (inputPath?.length === 1 && inputPath[0] === "tick-ctrl") { - return "number"; - } - } - setInputValue: (arg1: any, arg2: any, arg3: any) => void = ( inputPath, value, diff --git a/packages/perseus/src/widgets/numeric-input/numeric-input.tsx b/packages/perseus/src/widgets/numeric-input/numeric-input.tsx index b2606319f8..ee6011e1a8 100644 --- a/packages/perseus/src/widgets/numeric-input/numeric-input.tsx +++ b/packages/perseus/src/widgets/numeric-input/numeric-input.tsx @@ -163,11 +163,6 @@ export class NumericInput return [[]]; }; - getGrammarTypeForPath: (arg1: FocusPath) => string = (inputPath) => { - /* c8 ignore next */ - return "number"; - }; - setInputValue: ( arg1: FocusPath, arg2: string, diff --git a/packages/perseus/src/widgets/table/table.tsx b/packages/perseus/src/widgets/table/table.tsx index 645a89dac2..12c6258bbc 100644 --- a/packages/perseus/src/widgets/table/table.tsx +++ b/packages/perseus/src/widgets/table/table.tsx @@ -187,10 +187,6 @@ class Table extends React.Component implements Widget { return inputPaths; }; - getGrammarTypeForPath: (arg1: any) => string = (inputPath) => { - return "number"; - }; - setInputValue: (arg1: any, arg2: any, arg3: any) => void = ( path, newValue,