From afb14cff9f2108161968ef36a67852a1fccdcd99 Mon Sep 17 00:00:00 2001 From: Ned Redmond Date: Tue, 15 Aug 2023 12:33:25 -0400 Subject: [PATCH] Add ts lint rule for consistent type imports (#668) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - add rule and apply across packages - Create loud-doors-melt.md Author: nedredmond Reviewers: jeremywiebe, kevinbarabash, handeyeco Required Reviewers: Approved By: jeremywiebe Checks: ✅ finish_coverage, ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 16.x), ✅ Publish npm snapshot (ubuntu-latest, 16.x), ✅ Cypress Coverage (ubuntu-latest, 16.x), ✅ Extract i18n strings (ubuntu-latest, 16.x), ✅ Jest Coverage (ubuntu-latest, 16.x), ✅ Check builds for changes in size (ubuntu-latest, 16.x), ✅ gerald, ✅ Check for .changeset file (ubuntu-latest, 16.x) Pull Request URL: https://github.com/Khan/perseus/pull/668 --- .changeset/loud-doors-melt.md | 8 ++++++++ .eslintrc.js | 1 + .../math-input/src/components/input/math-wrapper.ts | 10 +++++++--- .../src/components/input/mathquill-helpers.ts | 8 +++----- .../src/components/input/mathquill-instance.ts | 2 +- .../src/components/input/mathquill-types.ts | 2 +- .../src/components/key-handlers/handle-arrow.ts | 7 ++++--- .../src/components/key-handlers/handle-backspace.ts | 5 +++-- .../src/components/key-handlers/handle-exponent.ts | 9 ++++----- .../src/components/key-handlers/handle-jump-out.ts | 9 ++++----- .../src/components/key-handlers/key-translator.ts | 11 ++++++----- .../keypad-legacy/compute-layout-parameters.ts | 2 +- .../src/components/keypad-legacy/echo-manager.tsx | 2 +- .../components/keypad-legacy/empty-keypad-button.tsx | 2 +- .../src/components/keypad-legacy/gesture-manager.ts | 8 ++++---- .../keypad-legacy/gesture-state-machine.ts | 2 +- .../src/components/keypad-legacy/keypad-button.tsx | 3 ++- .../components/keypad-legacy/many-keypad-button.tsx | 3 ++- .../components/keypad-legacy/multi-symbol-grid.tsx | 3 ++- .../keypad-legacy/multi-symbol-popover.tsx | 3 ++- .../src/components/keypad-legacy/node-manager.ts | 2 +- .../src/components/keypad-legacy/store/actions.ts | 3 +-- .../src/components/keypad-legacy/store/index.ts | 2 +- .../src/components/keypad-legacy/store/types.ts | 7 +++---- .../keypad-legacy/touchable-keypad-button.tsx | 6 +++--- .../src/components/keypad-legacy/two-page-keypad.tsx | 2 +- packages/math-input/src/components/keypad-switch.tsx | 3 ++- .../keypad/__tests__/keypad-v2-mathquill.test.tsx | 7 ++++--- .../src/components/keypad/button-assets.tsx | 2 +- .../src/components/keypad/keypad-button.stories.tsx | 6 ++++-- .../src/components/keypad/keypad-button.tsx | 3 +-- .../components/keypad/keypad-mathquill.stories.tsx | 5 +++-- .../components/keypad/keypad-pages/extras-page.tsx | 5 +++-- .../components/keypad/keypad-pages/geometry-page.tsx | 3 ++- .../components/keypad/keypad-pages/numbers-page.tsx | 3 ++- .../keypad/keypad-pages/operators-page.tsx | 3 ++- .../src/components/keypad/keypad.stories.tsx | 6 ++++-- packages/math-input/src/components/keypad/keypad.tsx | 6 +++--- .../src/components/keypad/mobile-keypad.tsx | 2 +- .../math-input/src/components/keypad/shared-keys.tsx | 5 +++-- packages/math-input/src/components/tabbar/tabbar.tsx | 6 ++++-- packages/math-input/src/data/key-configs.ts | 7 ++++--- packages/math-input/src/types.ts | 9 ++++----- .../src/__stories__/editor.stories.tsx | 4 +++- packages/perseus-editor/src/article-editor.tsx | 3 +-- .../src/components/form-wrapped-text-field.tsx | 4 +++- .../src/components/graph-points-count-selector.tsx | 4 +++- .../src/widgets/input-number-editor.tsx | 4 ++-- .../src/widgets/interactive-graph-editor.tsx | 12 ++++++++---- .../src/__tests__/server-item-renderer.test.tsx | 2 +- packages/perseus/src/components/math-input.tsx | 2 +- packages/perseus/src/components/sortable.tsx | 3 ++- packages/perseus/src/components/tex-buttons.tsx | 3 ++- packages/perseus/src/hints-renderer.tsx | 2 +- packages/perseus/src/types.ts | 3 +-- packages/perseus/src/widgets.ts | 2 +- .../perseus/src/widgets/__tests__/expression.test.ts | 3 ++- .../src/widgets/__tests__/interactive-graph.test.ts | 2 +- .../perseus/src/widgets/__tests__/plotter.test.tsx | 3 ++- packages/perseus/src/widgets/expression.tsx | 3 ++- packages/perseus/src/widgets/graded-group.tsx | 5 ++--- packages/perseus/src/widgets/interactive-graph.tsx | 8 +++++--- packages/perseus/src/widgets/passage-ref.tsx | 4 +--- packages/perseus/src/widgets/sequence.tsx | 2 +- packages/simple-markdown/src/index.ts | 3 +-- types/aphrodite.d.ts | 2 +- 66 files changed, 162 insertions(+), 124 deletions(-) create mode 100644 .changeset/loud-doors-melt.md diff --git a/.changeset/loud-doors-melt.md b/.changeset/loud-doors-melt.md new file mode 100644 index 0000000000..39d20260f5 --- /dev/null +++ b/.changeset/loud-doors-melt.md @@ -0,0 +1,8 @@ +--- +"@khanacademy/math-input": patch +"@khanacademy/perseus": patch +"@khanacademy/perseus-editor": patch +"@khanacademy/simple-markdown": patch +--- + +Add eslint rule to make type imports consistent diff --git a/.eslintrc.js b/.eslintrc.js index ed69aa1bc4..2f88a96b78 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -336,5 +336,6 @@ module.exports = { * typescript */ "@typescript-eslint/no-empty-function": "off", + "@typescript-eslint/consistent-type-imports": "error", }, }; diff --git a/packages/math-input/src/components/input/math-wrapper.ts b/packages/math-input/src/components/input/math-wrapper.ts index a606a2c357..ac88d97845 100644 --- a/packages/math-input/src/components/input/math-wrapper.ts +++ b/packages/math-input/src/components/input/math-wrapper.ts @@ -16,8 +16,6 @@ import $ from "jquery"; -import Key from "../../data/keys"; -import {Cursor} from "../../types"; import handleBackspace from "../key-handlers/handle-backspace"; import keyTranslator from "../key-handlers/key-translator"; @@ -27,7 +25,13 @@ import { maybeFindCommand, } from "./mathquill-helpers"; import {createMathField, mathQuillInstance} from "./mathquill-instance"; -import {MathFieldInterface, MathFieldUpdaterCallback} from "./mathquill-types"; + +import type Key from "../../data/keys"; +import type {Cursor} from "../../types"; +import type { + MathFieldInterface, + MathFieldUpdaterCallback, +} from "./mathquill-types"; const mobileKeyTranslator: Record = { ...keyTranslator, diff --git a/packages/math-input/src/components/input/mathquill-helpers.ts b/packages/math-input/src/components/input/mathquill-helpers.ts index df872c7f04..deaa031e15 100644 --- a/packages/math-input/src/components/input/mathquill-helpers.ts +++ b/packages/math-input/src/components/input/mathquill-helpers.ts @@ -1,10 +1,8 @@ import {CursorContext} from "./cursor-contexts"; import {mathQuillInstance} from "./mathquill-instance"; -import { - MathFieldActionType, - MathFieldCursor, - MathFieldInterface, -} from "./mathquill-types"; +import {MathFieldActionType} from "./mathquill-types"; + +import type {MathFieldCursor, MathFieldInterface} from "./mathquill-types"; const Numerals = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]; const GreekLetters = ["\\theta", "\\pi"]; diff --git a/packages/math-input/src/components/input/mathquill-instance.ts b/packages/math-input/src/components/input/mathquill-instance.ts index 1ecea2cf15..eda6d64f24 100644 --- a/packages/math-input/src/components/input/mathquill-instance.ts +++ b/packages/math-input/src/components/input/mathquill-instance.ts @@ -1,6 +1,6 @@ import MathQuill from "mathquill"; -import {MathQuillInterface, MathFieldConfig} from "./mathquill-types"; +import type {MathQuillInterface, MathFieldConfig} from "./mathquill-types"; // We only need one MathQuill instance (referred to as MQ in the docs) // and that contains some MQ constants and the MathField constructor diff --git a/packages/math-input/src/components/input/mathquill-types.ts b/packages/math-input/src/components/input/mathquill-types.ts index 44ef13b233..afb35d9ae7 100644 --- a/packages/math-input/src/components/input/mathquill-types.ts +++ b/packages/math-input/src/components/input/mathquill-types.ts @@ -1,4 +1,4 @@ -import Key from "../../data/keys"; +import type Key from "../../data/keys"; export interface MathQuillInterface { L: "L"; diff --git a/packages/math-input/src/components/key-handlers/handle-arrow.ts b/packages/math-input/src/components/key-handlers/handle-arrow.ts index e9f86515e0..7b3dc1508a 100644 --- a/packages/math-input/src/components/key-handlers/handle-arrow.ts +++ b/packages/math-input/src/components/key-handlers/handle-arrow.ts @@ -1,13 +1,14 @@ -import Key from "../../data/keys"; import { maybeFindCommand, maybeFindCommandBeforeParens, getCursor, } from "../input/mathquill-helpers"; import {mathQuillInstance} from "../input/mathquill-instance"; -import { +import {MathFieldActionType} from "../input/mathquill-types"; + +import type Key from "../../data/keys"; +import type { MathFieldInterface, - MathFieldActionType, MathFieldCursor, } from "../input/mathquill-types"; diff --git a/packages/math-input/src/components/key-handlers/handle-backspace.ts b/packages/math-input/src/components/key-handlers/handle-backspace.ts index 3b64dfda55..6b6f5ed0a6 100644 --- a/packages/math-input/src/components/key-handlers/handle-backspace.ts +++ b/packages/math-input/src/components/key-handlers/handle-backspace.ts @@ -10,8 +10,9 @@ import { maybeFindCommandBeforeParens, } from "../input/mathquill-helpers"; import {mathQuillInstance} from "../input/mathquill-instance"; -import { - MathFieldActionType, +import {MathFieldActionType} from "../input/mathquill-types"; + +import type { MathFieldInterface, MathFieldCursor, } from "../input/mathquill-types"; diff --git a/packages/math-input/src/components/key-handlers/handle-exponent.ts b/packages/math-input/src/components/key-handlers/handle-exponent.ts index 2260a9261a..62c347a9c4 100644 --- a/packages/math-input/src/components/key-handlers/handle-exponent.ts +++ b/packages/math-input/src/components/key-handlers/handle-exponent.ts @@ -1,10 +1,9 @@ -import Key from "../../data/keys"; import {getCursor} from "../input/mathquill-helpers"; import {mathQuillInstance} from "../input/mathquill-instance"; -import { - MathFieldInterface, - MathFieldActionType, -} from "../input/mathquill-types"; +import {MathFieldActionType} from "../input/mathquill-types"; + +import type Key from "../../data/keys"; +import type {MathFieldInterface} from "../input/mathquill-types"; const ArithmeticOperators = ["+", "-", "\\cdot", "\\times", "\\div"]; const EqualityOperators = ["=", "\\neq", "<", "\\leq", ">", "\\geq"]; diff --git a/packages/math-input/src/components/key-handlers/handle-jump-out.ts b/packages/math-input/src/components/key-handlers/handle-jump-out.ts index 8eb3ea976b..dd5df158e1 100644 --- a/packages/math-input/src/components/key-handlers/handle-jump-out.ts +++ b/packages/math-input/src/components/key-handlers/handle-jump-out.ts @@ -1,4 +1,3 @@ -import Key from "../../data/keys"; import {CursorContext} from "../input/cursor-contexts"; import { isFraction, @@ -7,10 +6,10 @@ import { getCursor, } from "../input/mathquill-helpers"; import {mathQuillInstance} from "../input/mathquill-instance"; -import { - MathFieldInterface, - MathFieldActionType, -} from "../input/mathquill-types"; +import {MathFieldActionType} from "../input/mathquill-types"; + +import type Key from "../../data/keys"; +import type {MathFieldInterface} from "../input/mathquill-types"; const KeysForJumpContext = { [CursorContext.IN_PARENS]: "JUMP_OUT_PARENTHESES", diff --git a/packages/math-input/src/components/key-handlers/key-translator.ts b/packages/math-input/src/components/key-handlers/key-translator.ts index 4be9e0c824..ca4c170e74 100644 --- a/packages/math-input/src/components/key-handlers/key-translator.ts +++ b/packages/math-input/src/components/key-handlers/key-translator.ts @@ -1,16 +1,17 @@ -import Key from "../../data/keys"; import {DecimalSeparator} from "../../enums"; import {decimalSeparator} from "../../utils"; import {mathQuillInstance} from "../input/mathquill-instance"; -import { - MathFieldInterface, - MathFieldUpdaterCallback, -} from "../input/mathquill-types"; import handleArrow from "./handle-arrow"; import handleExponent from "./handle-exponent"; import handleJumpOut from "./handle-jump-out"; +import type Key from "../../data/keys"; +import type { + MathFieldInterface, + MathFieldUpdaterCallback, +} from "../input/mathquill-types"; + enum ActionType { WRITE = "write", CMD = "cmd", diff --git a/packages/math-input/src/components/keypad-legacy/compute-layout-parameters.ts b/packages/math-input/src/components/keypad-legacy/compute-layout-parameters.ts index b0bbec3dc8..910cb3a498 100644 --- a/packages/math-input/src/components/keypad-legacy/compute-layout-parameters.ts +++ b/packages/math-input/src/components/keypad-legacy/compute-layout-parameters.ts @@ -27,7 +27,7 @@ import { innerBorderWidthPx, } from "../common-style"; -import {GridDimensions, WidthHeight} from "./store/types"; +import type {GridDimensions, WidthHeight} from "./store/types"; const minButtonHeight = 48; const maxButtonSize = 64; diff --git a/packages/math-input/src/components/keypad-legacy/echo-manager.tsx b/packages/math-input/src/components/keypad-legacy/echo-manager.tsx index efe2e3807c..bacc767670 100644 --- a/packages/math-input/src/components/keypad-legacy/echo-manager.tsx +++ b/packages/math-input/src/components/keypad-legacy/echo-manager.tsx @@ -6,12 +6,12 @@ import * as React from "react"; import {TransitionGroup, CSSTransition} from "react-transition-group"; import KeyConfigs from "../../data/key-configs"; -import Key from "../../data/keys"; import {EchoAnimationType} from "../../enums"; import KeypadButton from "./keypad-button"; import * as zIndexes from "./z-indexes"; +import type Key from "../../data/keys"; import type {Bound, Echo as EchoType} from "../../types"; type EchoProps = { diff --git a/packages/math-input/src/components/keypad-legacy/empty-keypad-button.tsx b/packages/math-input/src/components/keypad-legacy/empty-keypad-button.tsx index 621f4d5747..bb1362364f 100644 --- a/packages/math-input/src/components/keypad-legacy/empty-keypad-button.tsx +++ b/packages/math-input/src/components/keypad-legacy/empty-keypad-button.tsx @@ -7,9 +7,9 @@ import {connect} from "react-redux"; import KeyConfigs from "../../data/key-configs"; -import GestureManager from "./gesture-manager"; import KeypadButton from "./keypad-button"; +import type GestureManager from "./gesture-manager"; import type {State} from "./store/types"; interface ReduxProps { diff --git a/packages/math-input/src/components/keypad-legacy/gesture-manager.ts b/packages/math-input/src/components/keypad-legacy/gesture-manager.ts index b08988e76b..b53192d162 100644 --- a/packages/math-input/src/components/keypad-legacy/gesture-manager.ts +++ b/packages/math-input/src/components/keypad-legacy/gesture-manager.ts @@ -3,15 +3,15 @@ * connects our various bits of logic for managing gestures and interactions, * and links them together. */ -import * as React from "react"; - -import Key from "../../data/keys"; -import {ActiveNodesObj, LayoutProps} from "../../types"; import GestureStateMachine from "./gesture-state-machine"; import NodeManager from "./node-manager"; import PopoverStateMachine from "./popover-state-machine"; +import type Key from "../../data/keys"; +import type {ActiveNodesObj, LayoutProps} from "../../types"; +import type * as React from "react"; + const coordsForEvent = (evt) => { return [evt.changedTouches[0].clientX, evt.changedTouches[0].clientY]; }; diff --git a/packages/math-input/src/components/keypad-legacy/gesture-state-machine.ts b/packages/math-input/src/components/keypad-legacy/gesture-state-machine.ts index f207f13fe6..67acb9c43c 100644 --- a/packages/math-input/src/components/keypad-legacy/gesture-state-machine.ts +++ b/packages/math-input/src/components/keypad-legacy/gesture-state-machine.ts @@ -1,4 +1,4 @@ -import Key from "../../data/keys"; +import type Key from "../../data/keys"; /** * The state machine that backs our gesture system. In particular, this state diff --git a/packages/math-input/src/components/keypad-legacy/keypad-button.tsx b/packages/math-input/src/components/keypad-legacy/keypad-button.tsx index 868cc16f18..18e5117673 100644 --- a/packages/math-input/src/components/keypad-legacy/keypad-button.tsx +++ b/packages/math-input/src/components/keypad-legacy/keypad-button.tsx @@ -6,7 +6,7 @@ import {StyleSheet, css} from "aphrodite"; import * as React from "react"; import {connect} from "react-redux"; -import {BorderDirection, BorderStyles, KeyType, KeyTypes} from "../../enums"; +import {BorderDirection, BorderStyles, KeyTypes} from "../../enums"; import {View} from "../../fake-react-native-web/index"; import { wonderBlocksBlue, @@ -23,6 +23,7 @@ import CornerDecal from "./corner-decal"; import Icon from "./icon"; import MultiSymbolGrid from "./multi-symbol-grid"; +import type {KeyType} from "../../enums"; import type {Border, NonManyKeyConfig, IconConfig} from "../../types"; import type {State} from "./store/types"; import type {StyleType} from "@khanacademy/wonder-blocks-core"; diff --git a/packages/math-input/src/components/keypad-legacy/many-keypad-button.tsx b/packages/math-input/src/components/keypad-legacy/many-keypad-button.tsx index 557f0eeff7..b34e562414 100644 --- a/packages/math-input/src/components/keypad-legacy/many-keypad-button.tsx +++ b/packages/math-input/src/components/keypad-legacy/many-keypad-button.tsx @@ -7,11 +7,12 @@ import * as React from "react"; import KeyConfigs from "../../data/key-configs"; import {IconType} from "../../enums"; -import {KeyConfig} from "../../types"; import EmptyKeypadButton from "./empty-keypad-button"; import TouchableKeypadButton from "./touchable-keypad-button"; +import type {KeyConfig} from "../../types"; + type Props = { keys: ReadonlyArray; }; diff --git a/packages/math-input/src/components/keypad-legacy/multi-symbol-grid.tsx b/packages/math-input/src/components/keypad-legacy/multi-symbol-grid.tsx index 2ebae3c34c..7832fc296f 100644 --- a/packages/math-input/src/components/keypad-legacy/multi-symbol-grid.tsx +++ b/packages/math-input/src/components/keypad-legacy/multi-symbol-grid.tsx @@ -8,12 +8,13 @@ import * as React from "react"; import {IconType} from "../../enums"; import {View} from "../../fake-react-native-web/index"; -import {IconConfig} from "../../types"; import {iconSizeHeightPx, iconSizeWidthPx} from "../common-style"; import Icon from "./icon"; import Styles from "./styles"; +import type {IconConfig} from "../../types"; + const {row, column, centered, fullWidth} = Styles; type Props = { diff --git a/packages/math-input/src/components/keypad-legacy/multi-symbol-popover.tsx b/packages/math-input/src/components/keypad-legacy/multi-symbol-popover.tsx index 05f1d9f9cb..1dfbcbd7ae 100644 --- a/packages/math-input/src/components/keypad-legacy/multi-symbol-popover.tsx +++ b/packages/math-input/src/components/keypad-legacy/multi-symbol-popover.tsx @@ -7,11 +7,12 @@ import * as React from "react"; import {BorderStyles} from "../../enums"; import {View} from "../../fake-react-native-web/index"; -import {KeyConfig} from "../../types"; import TouchableKeypadButton from "./touchable-keypad-button"; import * as zIndexes from "./z-indexes"; +import type {KeyConfig} from "../../types"; + type Prop = { keys: ReadonlyArray; }; diff --git a/packages/math-input/src/components/keypad-legacy/node-manager.ts b/packages/math-input/src/components/keypad-legacy/node-manager.ts index 3479d90962..f5bbb72189 100644 --- a/packages/math-input/src/components/keypad-legacy/node-manager.ts +++ b/packages/math-input/src/components/keypad-legacy/node-manager.ts @@ -1,4 +1,4 @@ -import {LayoutProps, Bound} from "../../types"; +import type {LayoutProps, Bound} from "../../types"; /** * A manager for our node-to-ID system. In particular, this class is * responsible for maintaing a mapping between DOM nodes and node IDs, and diff --git a/packages/math-input/src/components/keypad-legacy/store/actions.ts b/packages/math-input/src/components/keypad-legacy/store/actions.ts index 5a45a85f9e..f8988824c0 100644 --- a/packages/math-input/src/components/keypad-legacy/store/actions.ts +++ b/packages/math-input/src/components/keypad-legacy/store/actions.ts @@ -1,5 +1,4 @@ -import Key from "../../../data/keys"; - +import type Key from "../../../data/keys"; import type { Bound, KeypadConfiguration, diff --git a/packages/math-input/src/components/keypad-legacy/store/index.ts b/packages/math-input/src/components/keypad-legacy/store/index.ts index 95703d67dc..f6ff80bd1f 100644 --- a/packages/math-input/src/components/keypad-legacy/store/index.ts +++ b/packages/math-input/src/components/keypad-legacy/store/index.ts @@ -1,6 +1,5 @@ import * as Redux from "redux"; -import Key from "../../../data/keys"; import GestureManager from "../gesture-manager"; import {setActiveNodes, pressKey} from "./actions"; @@ -10,6 +9,7 @@ import keypadReducer from "./keypad-reducer"; import layoutReducer from "./layout-reducer"; import {defaultKeypadType, keypadForType} from "./shared"; +import type Key from "../../../data/keys"; import type {LayoutProps, ActiveNodesObj} from "../../../types"; import type {Action} from "./actions"; import type {GestureState} from "./types"; diff --git a/packages/math-input/src/components/keypad-legacy/store/types.ts b/packages/math-input/src/components/keypad-legacy/store/types.ts index f4bd28ca32..0bf3c9c209 100644 --- a/packages/math-input/src/components/keypad-legacy/store/types.ts +++ b/packages/math-input/src/components/keypad-legacy/store/types.ts @@ -1,8 +1,7 @@ -import Key from "../../../data/keys"; -import {LayoutMode, KeypadType} from "../../../enums"; -import GestureManager from "../gesture-manager"; - +import type Key from "../../../data/keys"; +import type {LayoutMode, KeypadType} from "../../../enums"; import type {Cursor, KeyHandler, Popover, Echo} from "../../../types"; +import type GestureManager from "../gesture-manager"; // Interaction between keypad and input export interface InputState { diff --git a/packages/math-input/src/components/keypad-legacy/touchable-keypad-button.tsx b/packages/math-input/src/components/keypad-legacy/touchable-keypad-button.tsx index a41bc72ce0..e5eb36a009 100644 --- a/packages/math-input/src/components/keypad-legacy/touchable-keypad-button.tsx +++ b/packages/math-input/src/components/keypad-legacy/touchable-keypad-button.tsx @@ -10,13 +10,13 @@ import ReactDOM from "react-dom"; import {connect} from "react-redux"; import KeyConfigs from "../../data/key-configs"; -import Key from "../../data/keys"; -import {KeyType} from "../../enums"; -import GestureManager from "./gesture-manager"; import KeypadButton from "./keypad-button"; +import type Key from "../../data/keys"; +import type {KeyType} from "../../enums"; import type {Border, IconConfig, KeyConfig} from "../../types"; +import type GestureManager from "./gesture-manager"; import type {State} from "./store/types"; import type {StyleType} from "@khanacademy/wonder-blocks-core"; diff --git a/packages/math-input/src/components/keypad-legacy/two-page-keypad.tsx b/packages/math-input/src/components/keypad-legacy/two-page-keypad.tsx index 92247c56a4..a9244c1a14 100644 --- a/packages/math-input/src/components/keypad-legacy/two-page-keypad.tsx +++ b/packages/math-input/src/components/keypad-legacy/two-page-keypad.tsx @@ -17,10 +17,10 @@ import { import Tabbar from "../tabbar"; import Keypad from "./keypad"; -import {State as ReduxState} from "./store/types"; import Styles from "./styles"; import type {TabbarItemType} from "../tabbar"; +import type {State as ReduxState} from "./store/types"; const {column, row, fullWidth} = Styles; diff --git a/packages/math-input/src/components/keypad-switch.tsx b/packages/math-input/src/components/keypad-switch.tsx index a78f884887..8741c743e2 100644 --- a/packages/math-input/src/components/keypad-switch.tsx +++ b/packages/math-input/src/components/keypad-switch.tsx @@ -1,9 +1,10 @@ -import {StyleType} from "@khanacademy/wonder-blocks-core"; import * as React from "react"; import {MobileKeypad} from "./keypad"; import LegacyKeypad from "./keypad-legacy"; +import type {StyleType} from "@khanacademy/wonder-blocks-core"; + type Props = { onElementMounted?: (arg1: any) => void; onDismiss?: () => void; diff --git a/packages/math-input/src/components/keypad/__tests__/keypad-v2-mathquill.test.tsx b/packages/math-input/src/components/keypad/__tests__/keypad-v2-mathquill.test.tsx index 7d598f858b..5bad68fa1f 100644 --- a/packages/math-input/src/components/keypad/__tests__/keypad-v2-mathquill.test.tsx +++ b/packages/math-input/src/components/keypad/__tests__/keypad-v2-mathquill.test.tsx @@ -1,4 +1,3 @@ -import {PerseusAnalyticsEvent} from "@khanacademy/perseus-core"; import Color from "@khanacademy/wonder-blocks-color"; import {Popover} from "@khanacademy/wonder-blocks-popover"; import {render, screen} from "@testing-library/react"; @@ -7,12 +6,14 @@ import * as React from "react"; import "@testing-library/jest-dom"; -import Key from "../../../data/keys"; import {createMathField} from "../../input/mathquill-instance"; -import {MathFieldInterface} from "../../input/mathquill-types"; import keyTranslator from "../../key-handlers/key-translator"; import Keypad from "../index"; +import type Key from "../../../data/keys"; +import type {MathFieldInterface} from "../../input/mathquill-types"; +import type {PerseusAnalyticsEvent} from "@khanacademy/perseus-core"; + type Props = { onChangeMathInput: (mathInputTex: string) => void; keypadClosed?: boolean; diff --git a/packages/math-input/src/components/keypad/button-assets.tsx b/packages/math-input/src/components/keypad/button-assets.tsx index 5ec1e2098f..f4fdef53c7 100644 --- a/packages/math-input/src/components/keypad/button-assets.tsx +++ b/packages/math-input/src/components/keypad/button-assets.tsx @@ -12,7 +12,7 @@ no copying and pasting is necessary. */ import * as React from "react"; -import Key from "../../data/keys"; +import type Key from "../../data/keys"; type Props = {id: Key}; diff --git a/packages/math-input/src/components/keypad/keypad-button.stories.tsx b/packages/math-input/src/components/keypad/keypad-button.stories.tsx index 465731ff19..6114d032b4 100644 --- a/packages/math-input/src/components/keypad/keypad-button.stories.tsx +++ b/packages/math-input/src/components/keypad/keypad-button.stories.tsx @@ -1,10 +1,12 @@ import {action} from "@storybook/addon-actions"; -import {ComponentStory} from "@storybook/react"; import * as React from "react"; import KeyConfigs from "../../data/key-configs"; -import {KeypadButton, KeypadButtonProps} from "./keypad-button"; +import {KeypadButton} from "./keypad-button"; + +import type {KeypadButtonProps} from "./keypad-button"; +import type {ComponentStory} from "@storybook/react"; export default { title: "Keypad Button", diff --git a/packages/math-input/src/components/keypad/keypad-button.tsx b/packages/math-input/src/components/keypad/keypad-button.tsx index 9d98f5c093..70b6269464 100644 --- a/packages/math-input/src/components/keypad/keypad-button.tsx +++ b/packages/math-input/src/components/keypad/keypad-button.tsx @@ -4,10 +4,9 @@ import {View} from "@khanacademy/wonder-blocks-core"; import {StyleSheet} from "aphrodite"; import * as React from "react"; -import {KeyConfig, ClickKeyCallback} from "../../types"; - import ButtonAsset from "./button-assets"; +import type {KeyConfig, ClickKeyCallback} from "../../types"; import type {StyleType} from "@khanacademy/wonder-blocks-core"; export type KeypadButtonProps = { diff --git a/packages/math-input/src/components/keypad/keypad-mathquill.stories.tsx b/packages/math-input/src/components/keypad/keypad-mathquill.stories.tsx index a566953c55..f0e17ee60a 100644 --- a/packages/math-input/src/components/keypad/keypad-mathquill.stories.tsx +++ b/packages/math-input/src/components/keypad/keypad-mathquill.stories.tsx @@ -2,13 +2,14 @@ import Color from "@khanacademy/wonder-blocks-color"; import {Popover, PopoverContentCore} from "@khanacademy/wonder-blocks-popover"; import * as React from "react"; -import Key from "../../data/keys"; import {CursorContext} from "../input/cursor-contexts"; import {getCursorContext} from "../input/mathquill-helpers"; import {createMathField} from "../input/mathquill-instance"; -import {MathFieldInterface} from "../input/mathquill-types"; import keyTranslator from "../key-handlers/key-translator"; +import type Key from "../../data/keys"; +import type {MathFieldInterface} from "../input/mathquill-types"; + import Keypad from "./index"; export default { diff --git a/packages/math-input/src/components/keypad/keypad-pages/extras-page.tsx b/packages/math-input/src/components/keypad/keypad-pages/extras-page.tsx index 36184789bd..37d3130d0c 100644 --- a/packages/math-input/src/components/keypad/keypad-pages/extras-page.tsx +++ b/packages/math-input/src/components/keypad/keypad-pages/extras-page.tsx @@ -1,10 +1,11 @@ import * as React from "react"; import Keys from "../../../data/key-configs"; -import Key from "../../../data/keys"; -import {ClickKeyCallback} from "../../../types"; import {KeypadButton} from "../keypad-button"; +import type Key from "../../../data/keys"; +import type {ClickKeyCallback} from "../../../types"; + type Props = { extraKeys: ReadonlyArray; onClickKey: ClickKeyCallback; diff --git a/packages/math-input/src/components/keypad/keypad-pages/geometry-page.tsx b/packages/math-input/src/components/keypad/keypad-pages/geometry-page.tsx index 115401c6ee..8b894de13b 100644 --- a/packages/math-input/src/components/keypad/keypad-pages/geometry-page.tsx +++ b/packages/math-input/src/components/keypad/keypad-pages/geometry-page.tsx @@ -1,9 +1,10 @@ import * as React from "react"; import Keys from "../../../data/key-configs"; -import {ClickKeyCallback} from "../../../types"; import {KeypadButton} from "../keypad-button"; +import type {ClickKeyCallback} from "../../../types"; + type Props = { onClickKey: ClickKeyCallback; }; diff --git a/packages/math-input/src/components/keypad/keypad-pages/numbers-page.tsx b/packages/math-input/src/components/keypad/keypad-pages/numbers-page.tsx index 152355c007..3ba98c8d00 100644 --- a/packages/math-input/src/components/keypad/keypad-pages/numbers-page.tsx +++ b/packages/math-input/src/components/keypad/keypad-pages/numbers-page.tsx @@ -1,9 +1,10 @@ import * as React from "react"; import Keys from "../../../data/key-configs"; -import {ClickKeyCallback} from "../../../types"; import {KeypadButton} from "../keypad-button"; +import type {ClickKeyCallback} from "../../../types"; + type Props = { onClickKey: ClickKeyCallback; }; diff --git a/packages/math-input/src/components/keypad/keypad-pages/operators-page.tsx b/packages/math-input/src/components/keypad/keypad-pages/operators-page.tsx index 6f69ef3ade..6475706125 100644 --- a/packages/math-input/src/components/keypad/keypad-pages/operators-page.tsx +++ b/packages/math-input/src/components/keypad/keypad-pages/operators-page.tsx @@ -1,9 +1,10 @@ import * as React from "react"; import Keys from "../../../data/key-configs"; -import {ClickKeyCallback} from "../../../types"; import {KeypadButton} from "../keypad-button"; +import type {ClickKeyCallback} from "../../../types"; + type Props = { onClickKey: ClickKeyCallback; preAlgebra?: boolean; diff --git a/packages/math-input/src/components/keypad/keypad.stories.tsx b/packages/math-input/src/components/keypad/keypad.stories.tsx index 3b0b2eb99d..fb57909c4f 100644 --- a/packages/math-input/src/components/keypad/keypad.stories.tsx +++ b/packages/math-input/src/components/keypad/keypad.stories.tsx @@ -1,9 +1,11 @@ import {action} from "@storybook/addon-actions"; import {INITIAL_VIEWPORTS} from "@storybook/addon-viewport"; -import {ComponentStory} from "@storybook/react"; import * as React from "react"; -import Keypad, {Props as KeypadProps} from "./keypad"; +import Keypad from "./keypad"; + +import type {Props as KeypadProps} from "./keypad"; +import type {ComponentStory} from "@storybook/react"; const opsPage = "Operators Page"; const numsPage = "Numbers Page"; diff --git a/packages/math-input/src/components/keypad/keypad.tsx b/packages/math-input/src/components/keypad/keypad.tsx index 69e99aae6d..0115ff106d 100644 --- a/packages/math-input/src/components/keypad/keypad.tsx +++ b/packages/math-input/src/components/keypad/keypad.tsx @@ -4,9 +4,6 @@ import {StyleSheet} from "aphrodite"; import * as React from "react"; import {useEffect} from "react"; -import Key from "../../data/keys"; -import {ClickKeyCallback} from "../../types"; -import {CursorContext} from "../input/cursor-contexts"; import Tabbar from "../tabbar"; import ExtrasPage from "./keypad-pages/extras-page"; @@ -15,6 +12,9 @@ import NumbersPage from "./keypad-pages/numbers-page"; import OperatorsPage from "./keypad-pages/operators-page"; import SharedKeys from "./shared-keys"; +import type Key from "../../data/keys"; +import type {ClickKeyCallback} from "../../types"; +import type {CursorContext} from "../input/cursor-contexts"; import type {TabbarItemType} from "../tabbar"; import type {SendEventFn} from "@khanacademy/perseus-core"; diff --git a/packages/math-input/src/components/keypad/mobile-keypad.tsx b/packages/math-input/src/components/keypad/mobile-keypad.tsx index 672f8cfb01..350fe1309f 100644 --- a/packages/math-input/src/components/keypad/mobile-keypad.tsx +++ b/packages/math-input/src/components/keypad/mobile-keypad.tsx @@ -1,4 +1,3 @@ -import {StyleType} from "@khanacademy/wonder-blocks-core"; import {StyleSheet} from "aphrodite"; import * as React from "react"; import ReactDOM from "react-dom"; @@ -12,6 +11,7 @@ import type { KeyHandler, KeypadAPI, } from "../../types"; +import type {StyleType} from "@khanacademy/wonder-blocks-core"; import Keypad from "./index"; diff --git a/packages/math-input/src/components/keypad/shared-keys.tsx b/packages/math-input/src/components/keypad/shared-keys.tsx index a6a290ee95..ae03f519ac 100644 --- a/packages/math-input/src/components/keypad/shared-keys.tsx +++ b/packages/math-input/src/components/keypad/shared-keys.tsx @@ -1,12 +1,13 @@ import * as React from "react"; import Keys from "../../data/key-configs"; -import {ClickKeyCallback} from "../../types"; import {CursorContext} from "../input/cursor-contexts"; -import {TabbarItemType} from "../tabbar"; import {KeypadButton} from "./keypad-button"; +import type {ClickKeyCallback} from "../../types"; +import type {TabbarItemType} from "../tabbar"; + type Props = { onClickKey: ClickKeyCallback; selectedPage: TabbarItemType; diff --git a/packages/math-input/src/components/tabbar/tabbar.tsx b/packages/math-input/src/components/tabbar/tabbar.tsx index 3ac2aaea95..19f90c0427 100644 --- a/packages/math-input/src/components/tabbar/tabbar.tsx +++ b/packages/math-input/src/components/tabbar/tabbar.tsx @@ -1,9 +1,11 @@ -import {View, StyleType} from "@khanacademy/wonder-blocks-core"; +import {View} from "@khanacademy/wonder-blocks-core"; import {StyleSheet} from "aphrodite"; import * as React from "react"; import TabbarItem from "./item"; -import {TabbarItemType} from "./types"; + +import type {TabbarItemType} from "./types"; +import type {StyleType} from "@khanacademy/wonder-blocks-core"; const styles = StyleSheet.create({ tabbar: { diff --git a/packages/math-input/src/data/key-configs.ts b/packages/math-input/src/data/key-configs.ts index 15409756c5..f1dae53522 100644 --- a/packages/math-input/src/data/key-configs.ts +++ b/packages/math-input/src/data/key-configs.ts @@ -3,11 +3,12 @@ */ import * as i18n from "@khanacademy/wonder-blocks-i18n"; -import {DecimalSeparator, IconType, KeyType} from "../enums"; -import {KeyConfig} from "../types"; +import {DecimalSeparator, IconType} from "../enums"; import {decimalSeparator} from "../utils"; -import Key from "./keys"; +import type {KeyType} from "../enums"; +import type {KeyConfig} from "../types"; +import type Key from "./keys"; type KeyConfigMapper = (args: { key: Key; diff --git a/packages/math-input/src/types.ts b/packages/math-input/src/types.ts index 1dff56ae7c..aa2ec2094d 100644 --- a/packages/math-input/src/types.ts +++ b/packages/math-input/src/types.ts @@ -1,14 +1,13 @@ -import ReactDOM from "react-dom"; - -import {CursorContext} from "./components/input/cursor-contexts"; -import Key from "./data/keys"; -import { +import type {CursorContext} from "./components/input/cursor-contexts"; +import type Key from "./data/keys"; +import type { BorderDirection, EchoAnimationType, IconType, KeyType, KeypadType, } from "./enums"; +import type ReactDOM from "react-dom"; export type Border = Partial>; diff --git a/packages/perseus-editor/src/__stories__/editor.stories.tsx b/packages/perseus-editor/src/__stories__/editor.stories.tsx index 61b7b7c6ba..12033f8b3e 100644 --- a/packages/perseus-editor/src/__stories__/editor.stories.tsx +++ b/packages/perseus-editor/src/__stories__/editor.stories.tsx @@ -1,5 +1,5 @@ /* eslint-disable react/prop-types */ -import {ApiOptions, PerseusRenderer} from "@khanacademy/perseus"; +import {ApiOptions} from "@khanacademy/perseus"; import {View} from "@khanacademy/wonder-blocks-core"; import {action} from "@storybook/addon-actions"; import * as React from "react"; @@ -9,6 +9,8 @@ import {question1} from "../__testdata__/input-number.testdata"; import Editor from "../editor"; import {registerAllWidgetsAndEditorsForTesting} from "../util/register-all-widgets-and-editors-for-testing"; +import type {PerseusRenderer} from "@khanacademy/perseus"; + registerAllWidgetsAndEditorsForTesting(); // SIDE_EFFECTY!!!! :cry: export default { diff --git a/packages/perseus-editor/src/article-editor.tsx b/packages/perseus-editor/src/article-editor.tsx index 542f5b0a12..7bc9405861 100644 --- a/packages/perseus-editor/src/article-editor.tsx +++ b/packages/perseus-editor/src/article-editor.tsx @@ -8,7 +8,6 @@ import { components, icons, ApiOptions, - Changeable, Errors, PerseusError, } from "@khanacademy/perseus"; @@ -21,7 +20,7 @@ import SectionControlButton from "./components/section-control-button"; import Editor from "./editor"; import IframeContentRenderer from "./iframe-content-renderer"; -import type {APIOptions} from "@khanacademy/perseus"; +import type {APIOptions, Changeable} from "@khanacademy/perseus"; const {HUD, InlineIcon} = components; const {iconCircleArrowDown, iconCircleArrowUp, iconPlus, iconTrash} = icons; diff --git a/packages/perseus-editor/src/components/form-wrapped-text-field.tsx b/packages/perseus-editor/src/components/form-wrapped-text-field.tsx index 37e3784da8..8adcfe00f5 100644 --- a/packages/perseus-editor/src/components/form-wrapped-text-field.tsx +++ b/packages/perseus-editor/src/components/form-wrapped-text-field.tsx @@ -8,11 +8,13 @@ * If you need to handle `onSubmit`, please use directly with your * own
that wraps all text fields in the form. **/ -import {globalStyles, components} from "@khanacademy/perseus"; +import {globalStyles} from "@khanacademy/perseus"; import Color from "@khanacademy/wonder-blocks-color"; import {StyleSheet, css} from "aphrodite"; import * as React from "react"; +import type {components} from "@khanacademy/perseus"; + type Props = { // This id is used to tie the input field to the label that describes it. // TODO(diedra): Instead of passing in this id to connect the label and input diff --git a/packages/perseus-editor/src/components/graph-points-count-selector.tsx b/packages/perseus-editor/src/components/graph-points-count-selector.tsx index 41ac7485d8..5c80c74b0a 100644 --- a/packages/perseus-editor/src/components/graph-points-count-selector.tsx +++ b/packages/perseus-editor/src/components/graph-points-count-selector.tsx @@ -1,6 +1,8 @@ import * as React from "react"; -import {PointValue, UNLIMITED, parsePointCount} from "../util/points"; +import {UNLIMITED, parsePointCount} from "../util/points"; + +import type {PointValue} from "../util/points"; const GraphPointsCountSelector = ({ numPoints = 1, diff --git a/packages/perseus-editor/src/widgets/input-number-editor.tsx b/packages/perseus-editor/src/widgets/input-number-editor.tsx index 798872ce0b..615ee8b965 100644 --- a/packages/perseus-editor/src/widgets/input-number-editor.tsx +++ b/packages/perseus-editor/src/widgets/input-number-editor.tsx @@ -1,12 +1,12 @@ /* eslint-disable react/sort-comp */ -import {components, Util, InputNumber} from "@khanacademy/perseus"; +import {components, Util} from "@khanacademy/perseus"; import * as React from "react"; import ReactDOM from "react-dom"; import _ from "underscore"; import BlurInput from "../components/blur-input"; -import type {ParsedValue} from "@khanacademy/perseus"; +import type {ParsedValue, InputNumber} from "@khanacademy/perseus"; const {InfoTip} = components; diff --git a/packages/perseus-editor/src/widgets/interactive-graph-editor.tsx b/packages/perseus-editor/src/widgets/interactive-graph-editor.tsx index f2ec04bf48..7f835c8a6a 100644 --- a/packages/perseus-editor/src/widgets/interactive-graph-editor.tsx +++ b/packages/perseus-editor/src/widgets/interactive-graph-editor.tsx @@ -6,11 +6,8 @@ import { InteractiveGraphWidget, SizingUtils, Util, - PerseusImageBackground, - PerseusInteractiveGraphWidgetOptions, - APIOptionsWithDefaults, } from "@khanacademy/perseus"; -import {StyleType, View} from "@khanacademy/wonder-blocks-core"; +import {View} from "@khanacademy/wonder-blocks-core"; import Spacing from "@khanacademy/wonder-blocks-spacing"; import * as Typography from "@khanacademy/wonder-blocks-typography"; import * as React from "react"; @@ -22,6 +19,13 @@ import GraphTypeSelector from "../components/graph-type-selector"; import SegmentCountSelector from "../components/segment-count-selector"; import {parsePointCount} from "../util/points"; +import type { + PerseusImageBackground, + PerseusInteractiveGraphWidgetOptions, + APIOptionsWithDefaults, +} from "@khanacademy/perseus"; +import type {StyleType} from "@khanacademy/wonder-blocks-core"; + const {InfoTip} = components; const {containerSizeClass, getInteractiveBoxFromSizeClass} = SizingUtils; const DeprecationMixin = Util.DeprecationMixin; diff --git a/packages/perseus/src/__tests__/server-item-renderer.test.tsx b/packages/perseus/src/__tests__/server-item-renderer.test.tsx index 5f1d2a4c8e..a64af4130c 100644 --- a/packages/perseus/src/__tests__/server-item-renderer.test.tsx +++ b/packages/perseus/src/__tests__/server-item-renderer.test.tsx @@ -18,13 +18,13 @@ import InputNumberExport from "../widgets/input-number"; import RadioWidgetExport from "../widgets/radio"; import MockAssetLoadingWidgetExport, { - MockAssetLoadingWidget, mockedAssetItem, } from "./mock-asset-loading-widget"; import MockWidgetExport from "./mock-widget"; import type {PerseusItem} from "../perseus-types"; import type {APIOptions} from "../types"; +import type {MockAssetLoadingWidget} from "./mock-asset-loading-widget"; // This looks alot like `widgets/__tests__/renderQuestion.jsx', except we use // the ServerItemRenderer instead of Renderer diff --git a/packages/perseus/src/components/math-input.tsx b/packages/perseus/src/components/math-input.tsx index 9b4da1e47f..4002ec07b3 100644 --- a/packages/perseus/src/components/math-input.tsx +++ b/packages/perseus/src/components/math-input.tsx @@ -2,7 +2,6 @@ import { keyTranslator, createMathField, mathQuillInstance, - MathFieldInterface, } from "@khanacademy/math-input"; import classNames from "classnames"; import $ from "jquery"; @@ -13,6 +12,7 @@ import _ from "underscore"; import TexButtons from "./tex-buttons"; import type {ButtonSetsType} from "./tex-buttons"; +import type {MathFieldInterface} from "@khanacademy/math-input"; type ButtonsVisibleType = "always" | "never" | "focused"; diff --git a/packages/perseus/src/components/sortable.tsx b/packages/perseus/src/components/sortable.tsx index 5b84e44c43..349eaf213a 100644 --- a/packages/perseus/src/components/sortable.tsx +++ b/packages/perseus/src/components/sortable.tsx @@ -11,9 +11,10 @@ import _ from "underscore"; import {getDependencies} from "../dependencies"; import {ClassNames as ApiClassNames} from "../perseus-api"; import Renderer from "../renderer"; -import Util, {Position} from "../util"; +import Util from "../util"; import type {LinterContextProps} from "../types"; +import type {Position} from "../util"; export enum Layout { HORIZONTAL = "horizontal", diff --git a/packages/perseus/src/components/tex-buttons.tsx b/packages/perseus/src/components/tex-buttons.tsx index 01c1dfb08d..6b18cea45a 100644 --- a/packages/perseus/src/components/tex-buttons.tsx +++ b/packages/perseus/src/components/tex-buttons.tsx @@ -1,5 +1,4 @@ /* eslint-disable @khanacademy/ts-no-error-suppressions */ -import {Keys} from "@khanacademy/math-input"; import * as i18n from "@khanacademy/wonder-blocks-i18n"; import PropTypes from "prop-types"; import * as React from "react"; @@ -7,6 +6,8 @@ import _ from "underscore"; import {getDependencies} from "../dependencies"; +import type {Keys} from "@khanacademy/math-input"; + const prettyBig = {fontSize: "150%"} as const; const slightlyBig = {fontSize: "120%"} as const; const symbStyle = {fontSize: "130%"} as const; diff --git a/packages/perseus/src/hints-renderer.tsx b/packages/perseus/src/hints-renderer.tsx index e408f95839..452956d9e0 100644 --- a/packages/perseus/src/hints-renderer.tsx +++ b/packages/perseus/src/hints-renderer.tsx @@ -9,7 +9,6 @@ import _ from "underscore"; import HintRenderer from "./hint-renderer"; import {ApiOptions} from "./perseus-api"; -import Renderer from "./renderer"; import { baseUnitPx, hintBorderWidth, @@ -21,6 +20,7 @@ import mediaQueries from "./styles/media-queries"; import sharedStyles from "./styles/shared"; import Util from "./util"; +import type Renderer from "./renderer"; import type {APIOptionsWithDefaults} from "./types"; type Props = JSX.LibraryManagedAttributes< diff --git a/packages/perseus/src/types.ts b/packages/perseus/src/types.ts index ddf0702e80..78b0118136 100644 --- a/packages/perseus/src/types.ts +++ b/packages/perseus/src/types.ts @@ -1,5 +1,3 @@ -import * as React from "react"; - import type {SerializedHighlightSet} from "./components/highlighting/types"; import type {ILogger} from "./logging/log"; import type {Item} from "./multi-items/item-types"; @@ -8,6 +6,7 @@ import type {SizeClass} from "./util/sizing-utils"; import type {KeypadAPI} from "@khanacademy/math-input"; import type {SendEventFn} from "@khanacademy/perseus-core"; import type {Result} from "@khanacademy/wonder-blocks-data"; +import type * as React from "react"; export type FocusPath = ReadonlyArray | null | undefined; diff --git a/packages/perseus/src/widgets.ts b/packages/perseus/src/widgets.ts index 846175d93e..c4486f3bb4 100644 --- a/packages/perseus/src/widgets.ts +++ b/packages/perseus/src/widgets.ts @@ -1,4 +1,3 @@ -import * as React from "react"; import _ from "underscore"; import {Errors, Log} from "./logging/log"; @@ -12,6 +11,7 @@ import type { WidgetInfo, WidgetTransform, } from "./types"; +import type * as React from "react"; const DEFAULT_ALIGNMENT = "block"; // NOTE(kevinb): "default" is not one in `validAlignments`. diff --git a/packages/perseus/src/widgets/__tests__/expression.test.ts b/packages/perseus/src/widgets/__tests__/expression.test.ts index b0cc81662a..e3ba676119 100644 --- a/packages/perseus/src/widgets/__tests__/expression.test.ts +++ b/packages/perseus/src/widgets/__tests__/expression.test.ts @@ -5,7 +5,6 @@ import "@testing-library/jest-dom"; import {testDependencies} from "../../../../../testing/test-dependencies"; import * as Dependencies from "../../dependencies"; -import {PerseusItem} from "../../perseus-types"; import { expressionItem2, expressionItem3, @@ -15,6 +14,8 @@ import {Expression} from "../expression"; import {renderQuestion} from "./renderQuestion"; +import type {PerseusItem} from "../../perseus-types"; + const assertComplete = (itemData: PerseusItem, input, isCorrect: boolean) => { const {renderer} = renderQuestion(itemData.question); userEvent.type(screen.getByRole("textbox"), input); diff --git a/packages/perseus/src/widgets/__tests__/interactive-graph.test.ts b/packages/perseus/src/widgets/__tests__/interactive-graph.test.ts index 91b412840e..d3ec88b157 100644 --- a/packages/perseus/src/widgets/__tests__/interactive-graph.test.ts +++ b/packages/perseus/src/widgets/__tests__/interactive-graph.test.ts @@ -4,13 +4,13 @@ import {clone} from "../../../../../testing/object-utils"; import {testDependencies} from "../../../../../testing/test-dependencies"; import * as Dependencies from "../../dependencies"; import {ApiOptions} from "../../perseus-api"; -import Renderer from "../../renderer"; import {questionsAndAnswers} from "../__testdata__/interactive-graph.testdata"; import {renderQuestion} from "./renderQuestion"; import type {Coord} from "../../interactive2/types"; import type {PerseusRenderer} from "../../perseus-types"; +import type Renderer from "../../renderer"; import type {APIOptions} from "../../types"; const updateWidgetState = (renderer: Renderer, widgetId: string, update) => { diff --git a/packages/perseus/src/widgets/__tests__/plotter.test.tsx b/packages/perseus/src/widgets/__tests__/plotter.test.tsx index 06a5a3c921..c4d0cda7b7 100644 --- a/packages/perseus/src/widgets/__tests__/plotter.test.tsx +++ b/packages/perseus/src/widgets/__tests__/plotter.test.tsx @@ -4,12 +4,13 @@ import React from "react"; import {testDependencies} from "../../../../../testing/test-dependencies"; import {setDependencies} from "../../dependencies"; -import {APIOptions} from "../../types"; import {question1} from "../__testdata__/plotter.testdata"; import {Plotter} from "../plotter"; import {renderQuestion} from "./renderQuestion"; +import type {APIOptions} from "../../types"; + describe("plotter widget", () => { beforeEach(() => { setDependencies(testDependencies); diff --git a/packages/perseus/src/widgets/expression.tsx b/packages/perseus/src/widgets/expression.tsx index 771e3efd92..772bb6692d 100644 --- a/packages/perseus/src/widgets/expression.tsx +++ b/packages/perseus/src/widgets/expression.tsx @@ -1,5 +1,5 @@ import * as KAS from "@khanacademy/kas"; -import {KeypadInput, KeypadType, Keys as Key} from "@khanacademy/math-input"; +import {KeypadInput, KeypadType} from "@khanacademy/math-input"; import {linterContextDefault} from "@khanacademy/perseus-linter"; import * as i18n from "@khanacademy/wonder-blocks-i18n"; import classNames from "classnames"; @@ -24,6 +24,7 @@ import type { PerseusExpressionAnswerForm, } from "../perseus-types"; import type {PerseusScore, WidgetExports, WidgetProps} from "../types"; +import type {Keys as Key} from "@khanacademy/math-input"; const sendExpressionEvaluatedEvent = ( result: "correct" | "incorrect" | "invalid", diff --git a/packages/perseus/src/widgets/graded-group.tsx b/packages/perseus/src/widgets/graded-group.tsx index d9106e5fff..17e02d038d 100644 --- a/packages/perseus/src/widgets/graded-group.tsx +++ b/packages/perseus/src/widgets/graded-group.tsx @@ -22,12 +22,11 @@ import { } from "../styles/constants"; import a11y from "../util/a11y"; -import GradedGroupAnswerBar, { - ANSWER_BAR_STATES, -} from "./graded-group-answer-bar"; +import GradedGroupAnswerBar from "./graded-group-answer-bar"; import type {PerseusGradedGroupWidgetOptions} from "../perseus-types"; import type {PerseusScore, WidgetExports, WidgetProps} from "../types"; +import type {ANSWER_BAR_STATES} from "./graded-group-answer-bar"; const GRADING_STATUSES = { ungraded: "ungraded" as const, diff --git a/packages/perseus/src/widgets/interactive-graph.tsx b/packages/perseus/src/widgets/interactive-graph.tsx index 7612f9fab3..57759b0245 100644 --- a/packages/perseus/src/widgets/interactive-graph.tsx +++ b/packages/perseus/src/widgets/interactive-graph.tsx @@ -14,9 +14,6 @@ import {PerseusError} from "../perseus-error"; import Util from "../util"; import KhanColors from "../util/colors"; import { - QuadraticCoefficient, - SineCoefficient, - Range, angleMeasures, ccw, collinear, @@ -44,6 +41,11 @@ import type { PerseusInteractiveGraphWidgetOptions, } from "../perseus-types"; import type {PerseusScore, WidgetExports, WidgetProps} from "../types"; +import type { + QuadraticCoefficient, + SineCoefficient, + Range, +} from "../util/geometry"; const {DeprecationMixin} = Util; diff --git a/packages/perseus/src/widgets/passage-ref.tsx b/packages/perseus/src/widgets/passage-ref.tsx index 90ccb8a45e..f7fa6f5d13 100644 --- a/packages/perseus/src/widgets/passage-ref.tsx +++ b/packages/perseus/src/widgets/passage-ref.tsx @@ -7,8 +7,6 @@ import * as Changeable from "../mixins/changeable"; import {removeDenylistProps} from "../mixins/widget-prop-denylist"; import PerseusMarkdown from "../perseus-markdown"; -import {Passage} from "./passage"; - import type {PerseusPassageRefWidgetOptions} from "../perseus-types"; import type { ChangeFn, @@ -17,7 +15,7 @@ import type { WidgetProps, LinterContextProps, } from "../types"; -import type {Reference} from "./passage"; +import type {Passage, Reference} from "./passage"; const EN_DASH = "\u2013"; diff --git a/packages/perseus/src/widgets/sequence.tsx b/packages/perseus/src/widgets/sequence.tsx index 13a586a882..be0741b7ae 100644 --- a/packages/perseus/src/widgets/sequence.tsx +++ b/packages/perseus/src/widgets/sequence.tsx @@ -5,10 +5,10 @@ import _ from "underscore"; import InlineIcon from "../components/inline-icon"; import {iconOk} from "../icon-paths"; import * as Changeable from "../mixins/changeable"; -import {PerseusSequenceWidgetOptions} from "../perseus-types"; import Renderer from "../renderer"; import Util from "../util"; +import type {PerseusSequenceWidgetOptions} from "../perseus-types"; import type {WidgetExports, WidgetProps} from "../types"; type Rubric = PerseusSequenceWidgetOptions; diff --git a/packages/simple-markdown/src/index.ts b/packages/simple-markdown/src/index.ts index 78ede7b517..0222c4db37 100644 --- a/packages/simple-markdown/src/index.ts +++ b/packages/simple-markdown/src/index.ts @@ -18,9 +18,8 @@ * Many of the regexes and original logic has been adapted from * the wonderful [marked.js](https://github.com/chjj/marked) */ -import * as React from "react"; - import type {Capture, MatchFunction, State} from "./troublesome-types"; +import type * as React from "react"; // Type Definitions: diff --git a/types/aphrodite.d.ts b/types/aphrodite.d.ts index dafec4193e..f6646b71d9 100644 --- a/types/aphrodite.d.ts +++ b/types/aphrodite.d.ts @@ -1,5 +1,5 @@ declare module "aphrodite" { - import * as React from "react"; + import type * as React from "react"; type _CSSProperties = Omit< React.CSSProperties,