@khanacademy/perseus 4.0.0 → 4.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/components/highlighting/ui/highlighting-ui.d.ts +1 -1
  3. package/dist/es/index.js +7968 -8296
  4. package/dist/es/index.js.map +1 -1
  5. package/dist/index.js +46 -223
  6. package/dist/index.js.map +1 -1
  7. package/dist/multi-items/multi-renderer.d.ts +1 -1
  8. package/dist/multi-items/multi-renderer.js.flow +1 -1
  9. package/dist/multi-items/prop-type-builders.d.ts +1 -1
  10. package/dist/multi-items/shape-types.d.ts +1 -1
  11. package/dist/multi-items/shape-types.js.flow +1 -1
  12. package/dist/multi-items/tree-types.d.ts +1 -1
  13. package/dist/multi-items/tree-types.js.flow +1 -1
  14. package/dist/widgets/__stories__/test-keypad-context-wrapper.d.ts +6 -0
  15. package/dist/widgets/__stories__/test-keypad-context-wrapper.js.flow +14 -0
  16. package/package.json +8 -8
  17. package/src/__testdata__/item-renderer.testdata.ts +1 -1
  18. package/src/__testdata__/renderer.testdata.ts +1 -1
  19. package/src/__tests__/item-renderer.test.tsx +1 -2
  20. package/src/__tests__/renderer-api.test.tsx +1 -5
  21. package/src/__tests__/renderer.test.tsx +1 -1
  22. package/src/components/fixed-to-responsive.tsx +0 -1
  23. package/src/components/graph.tsx +0 -4
  24. package/src/components/highlighting/ui/highlighting-ui.tsx +3 -13
  25. package/src/components/highlighting/ui/selection-tracker.tsx +1 -1
  26. package/src/components/highlighting/word-indexer.tsx +0 -4
  27. package/src/components/math-input.tsx +0 -2
  28. package/src/components/number-input.tsx +0 -2
  29. package/src/components/text-list-editor.tsx +0 -4
  30. package/src/components/zoomable-tex.tsx +0 -2
  31. package/src/components/zoomable.tsx +0 -4
  32. package/src/definition-context.tsx +0 -1
  33. package/src/hints-renderer.tsx +1 -1
  34. package/src/interactive2/__tests__/movable-point.test.ts +0 -1
  35. package/src/item-renderer.tsx +0 -5
  36. package/src/mixins/changeable.ts +1 -1
  37. package/src/multi-items/__stories__/multi-renderer.stories.tsx +0 -4
  38. package/src/multi-items/__tests__/items.test.ts +3 -13
  39. package/src/multi-items/__tests__/multi-renderer.test.tsx +1 -1
  40. package/src/multi-items/__tests__/prop-type-builders.test.ts +1 -1
  41. package/src/multi-items/__tests__/trees.test.ts +2 -10
  42. package/src/multi-items/multi-renderer.tsx +7 -10
  43. package/src/multi-items/prop-type-builders.ts +1 -1
  44. package/src/multi-items/shape-types.ts +1 -1
  45. package/src/multi-items/tree-types.ts +1 -1
  46. package/src/perseus-markdown.tsx +0 -2
  47. package/src/perseus-types.ts +1 -1
  48. package/src/renderer.tsx +2 -5
  49. package/src/server-item-renderer.tsx +0 -3
  50. package/src/util/interactive.ts +1 -5
  51. package/src/util/math.ts +0 -3
  52. package/src/widgets/__stories__/expression.stories.tsx +113 -7
  53. package/src/widgets/__stories__/image.stories.tsx +1 -1
  54. package/src/widgets/__stories__/{on-screen-keypad.stories.tsx → test-keypad-context-wrapper.tsx} +17 -57
  55. package/src/widgets/__testdata__/expression.testdata.ts +16 -12
  56. package/src/widgets/__testdata__/numeric-input.testdata.ts +0 -1
  57. package/src/widgets/__testdata__/transformer.testdata.ts +0 -1
  58. package/src/widgets/__tests__/radio.test.ts +1 -1
  59. package/src/widgets/expression.tsx +1 -1
  60. package/src/widgets/graded-group-set.tsx +0 -4
  61. package/src/widgets/graded-group.tsx +0 -4
  62. package/src/widgets/grapher/util.tsx +1 -5
  63. package/src/widgets/grapher.tsx +0 -5
  64. package/src/widgets/group.tsx +0 -1
  65. package/src/widgets/interaction.tsx +0 -1
  66. package/src/widgets/interactive-graph.tsx +3 -62
  67. package/src/widgets/label-image.tsx +1 -1
  68. package/src/widgets/measurer.tsx +0 -1
  69. package/src/widgets/number-line.tsx +0 -2
  70. package/src/widgets/orderer.tsx +0 -3
  71. package/src/widgets/passage/passage-markdown.tsx +1 -1
  72. package/src/widgets/passage-ref-target.tsx +0 -1
  73. package/src/widgets/passage.tsx +1 -1
  74. package/src/widgets/plotter.tsx +0 -1
  75. package/src/widgets/radio/__stories__/base-radio.stories.tsx +2 -2
  76. package/src/widgets/radio/base-radio.tsx +1 -1
  77. package/src/widgets/transformer.tsx +1 -16
  78. package/src/widgets.ts +1 -1
  79. package/src/zoom.ts +0 -3
  80. package/tsconfig.tsbuildinfo +1 -1
  81. /package/dist/{strings → strings.js} +0 -0
@@ -27,7 +27,7 @@ type RendererData = ContentRendererData | HintRendererData;
27
27
  type RendererDataTree = Tree<ContentRendererData, HintRendererData, null>;
28
28
  /**
29
29
  * TODO(somewhatabstract, JIRA-XXXX):
30
- * Some usage of this type somewhere is causing Flow to believe that these
30
+ * Some usage of this type somewhere is causing TypeScript to believe that these
31
31
  * elements should be components. Don't know where that is, to fix it up
32
32
  * properly. In reality, these types are just too hard to use and aren't
33
33
  * really helping us out as I now have to suppress this rather than
@@ -39,7 +39,7 @@ declare type RendererDataTree = Tree<
39
39
  >;
40
40
  /**
41
41
  * TODO(somewhatabstract, JIRA-XXXX):
42
- * Some usage of this type somewhere is causing Flow to believe that these
42
+ * Some usage of this type somewhere is causing TypeScript to believe that these
43
43
  * elements should be components. Don't know where that is, to fix it up
44
44
  * properly. In reality, these types are just too hard to use and aren't
45
45
  * really helping us out as I now have to suppress this rather than
@@ -2,7 +2,7 @@
2
2
  * Utility functions to build React PropTypes for multi-items and shapes.
3
3
  *
4
4
  * If you're writing new components, though, consider using the Item and Shape
5
- * Flow types instead.
5
+ * types instead.
6
6
  */
7
7
  import type { Shape } from "./shape-types";
8
8
  /**
@@ -11,7 +11,7 @@
11
11
  * Shapes also enable us to traverse a multi-item-shaped tree with confidence,
12
12
  * even when we can't infer the shape from the tree alone.
13
13
  *
14
- * We *could* go all-in on a more general library to make certain Flow types
14
+ * We *could* go all-in on a more general library to make certain types
15
15
  * runtime-inspectable, in order to DRY some things up, but that's probably a
16
16
  * big ol' infrastructural magic mess, and the narrower scope of Shapes makes
17
17
  * it easier to be confident that we've covered all cases rather than having to
@@ -17,7 +17,7 @@
17
17
  * Shapes also enable us to traverse a multi-item-shaped tree with confidence,
18
18
  * even when we can't infer the shape from the tree alone.
19
19
  *
20
- * We *could* go all-in on a more general library to make certain Flow types
20
+ * We *could* go all-in on a more general library to make certain types
21
21
  * runtime-inspectable, in order to DRY some things up, but that's probably a
22
22
  * big ol' infrastructural magic mess, and the narrower scope of Shapes makes
23
23
  * it easier to be confident that we've covered all cases rather than having to
@@ -28,7 +28,7 @@ export type ObjectNode<C, H, T> = {
28
28
  * TODO(somewhatabstract, JIRA-XXXX):
29
29
  * We should ditch this type or create some helpers for working with it.
30
30
  * As it stands, consumers have to check each node's type before using it
31
- * in order to ensure that flow can track its refinement and appropriate use.
31
+ * in order to ensure that TypeScript can track its refinement and appropriate use.
32
32
  * It's messy.
33
33
  */
34
34
  export type Tree<C, H, T> = C | H | T | ArrayNode<C, H, T> | ObjectNode<C, H, T>;
@@ -34,7 +34,7 @@ export type ObjectNode<C, H, T> = {
34
34
  * TODO(somewhatabstract, JIRA-XXXX):
35
35
  * We should ditch this type or create some helpers for working with it.
36
36
  * As it stands, consumers have to check each node's type before using it
37
- * in order to ensure that flow can track its refinement and appropriate use.
37
+ * in order to ensure that TypeScript can track its refinement and appropriate use.
38
38
  * It's messy.
39
39
  */
40
40
  export type Tree<C, H, T> =
@@ -0,0 +1,6 @@
1
+ import * as React from "react";
2
+ type TestKeypadContextWrapperProps = {
3
+ children: React.ReactElement;
4
+ };
5
+ declare const TestKeypadContextWrapper: (props: TestKeypadContextWrapperProps) => React.ReactElement;
6
+ export default TestKeypadContextWrapper;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Flowtype definitions for data
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.21.0
5
+ * @flow
6
+ */
7
+ import * as React from "react";
8
+ declare type TestKeypadContextWrapperProps = {|
9
+ children: React.Element<any>,
10
+ |};
11
+ declare var TestKeypadContextWrapper: (
12
+ props: TestKeypadContextWrapperProps
13
+ ) => React.Element<any>;
14
+ declare export default typeof TestKeypadContextWrapper;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Core Perseus API (includes renderers and widgets)",
4
4
  "author": "Khan Academy",
5
5
  "license": "MIT",
6
- "version": "4.0.0",
6
+ "version": "4.0.2",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -21,12 +21,12 @@
21
21
  "test": "bash -c 'yarn --silent --cwd \"../..\" test ${@:0} $($([[ ${@: -1} = -* ]] || [[ ${@: -1} = bash ]]) && echo $PWD)'"
22
22
  },
23
23
  "dependencies": {
24
- "@khanacademy/kas": "^0.3.0",
25
- "@khanacademy/kmath": "^0.1.0",
26
- "@khanacademy/math-input": "^0.7.0",
27
- "@khanacademy/perseus-linter": "^0.3.0",
28
- "@khanacademy/pure-markdown": "^0.2.0",
29
- "@khanacademy/simple-markdown": "^0.9.0",
24
+ "@khanacademy/kas": "^0.3.1",
25
+ "@khanacademy/kmath": "^0.1.1",
26
+ "@khanacademy/math-input": "^0.7.2",
27
+ "@khanacademy/perseus-linter": "^0.3.1",
28
+ "@khanacademy/pure-markdown": "^0.2.2",
29
+ "@khanacademy/simple-markdown": "^0.9.2",
30
30
  "mathquill": "git+https://git@github.com/Khan/mathquill.git#a9ae54e057c5c1acc8244a5627acbff29901d992"
31
31
  },
32
32
  "devDependencies": {
@@ -56,7 +56,7 @@
56
56
  "jquery": "^2.1.1",
57
57
  "katex": "^0.11.1",
58
58
  "lodash.debounce": "^4.0.8",
59
- "perseus-build-settings": "^0.0.5",
59
+ "perseus-build-settings": "^0.1.0",
60
60
  "prop-types": "^15.6.1",
61
61
  "react": "16.14.0",
62
62
  "react-dom": "16.14.0",
@@ -111,7 +111,7 @@ export const labelImageItem: PerseusItem = {
111
111
  export const mockedItem: PerseusItem = {
112
112
  // The mock widget type is not part of the PerseusWidget type union (and
113
113
  // we don't want to make it such to avoid polluting our production types
114
- // for test purposes) so we force Flow to accept it here.
114
+ // for test purposes) so we force TypeScript to accept it here.
115
115
  // @ts-expect-error [FEI-5003] - TS2352 - Conversion of type '{ content: string; images: {}; widgets: { "mock-widget 1": { graded: true; version: { major: number; minor: number; }; static: false; type: "mock-widget"; options: { static: false; smiling: boolean; }; alignment: string; }; "mock-widget 2": { ...; }; "mock-widget 3": { ...; }; "mock-widget 4": { ...; }; }; }' to type 'PerseusRenderer' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
116
116
  question: {
117
117
  content:
@@ -89,7 +89,7 @@ export const question2: PerseusRenderer = {
89
89
  export const mockedItem: PerseusRenderer = {
90
90
  // The mock widget type is not part of the PerseusWidget type union (and
91
91
  // we don't want to make it such to avoid polluting our production types
92
- // for test purposes) so we force Flow to accept it here.
92
+ // for test purposes) so we force TypeScript to accept it here.
93
93
  content:
94
94
  "Mock widgets ==> [[\u2603 mock-widget 1]] [[\u2603 mock-widget 2]] [[\u2603 mock-widget 3]]",
95
95
  images: {},
@@ -93,7 +93,7 @@ export const renderQuestion = (
93
93
  };
94
94
 
95
95
  // Finds a widget in the given renderer by ID. The return type is non-optional
96
- // (ie. it assumes the widget will exist) to make Flow happier in the tests
96
+ // (ie. it assumes the widget will exist) to make TypeScript happier in the tests
97
97
  // that use this function.
98
98
  const getWidgetById = (
99
99
  renderer: ItemRenderer,
@@ -111,7 +111,6 @@ const makeHint = (content: string): PerseusRenderer => ({
111
111
  content:
112
112
  "Maybe if you try using a calculator? See: [[\u2603 mock-hint-widget 1]]",
113
113
  widgets: {
114
- // $FlowFixMe[incompatible-return]
115
114
  "mock-hint-widget 1": {
116
115
  graded: true,
117
116
  version: {major: 0, minor: 0},
@@ -33,7 +33,6 @@ const delayedPromise = (value: undefined) => {
33
33
  const renderQuestionArea = function (item, apiOptions): any {
34
34
  const wrapper = mount(
35
35
  <RenderStateRoot>
36
- {/* $FlowFixMe[prop-missing] */}
37
36
  <Renderer
38
37
  content={item.question.content}
39
38
  images={item.question.images}
@@ -171,9 +170,8 @@ describe("Perseus API", function () {
171
170
  renderer.setInputValue(widgetId, "5");
172
171
  },
173
172
  });
173
+
174
174
  const input =
175
- // $FlowFixMe[incompatible-use]
176
- // $FlowFixMe[prop-missing]
177
175
  // @ts-expect-error [FEI-5003] - TS2531 - Object is possibly 'null'. | TS2339 - Property 'querySelector' does not exist on type 'Element | Text'.
178
176
  ReactDOM.findDOMNode(renderer).querySelector("input");
179
177
 
@@ -251,8 +249,6 @@ describe("Perseus API", function () {
251
249
  });
252
250
 
253
251
  const inputs =
254
- // $FlowFixMe[incompatible-use]
255
- // $FlowFixMe[prop-missing]
256
252
  // @ts-expect-error [FEI-5003] - TS2531 - Object is possibly 'null'. | TS2339 - Property 'querySelectorAll' does not exist on type 'Element | Text'.
257
253
  ReactDOM.findDOMNode(renderer).querySelectorAll("input");
258
254
  const input1 = inputs[0];
@@ -184,7 +184,7 @@ describe("renderer", () => {
184
184
 
185
185
  it("should derive type widget ID if type missing", () => {
186
186
  // Arrange
187
- // Note that the Flow types disallow this, but our Renderer handles the
187
+ // Note that the types disallow this, but our Renderer handles the
188
188
  // case so for now, I'm adding this test. We can remove the test
189
189
  // if/when we clean up the code for it in _getAllWidgetsInfo().
190
190
  const question = {
@@ -103,7 +103,6 @@ const FixedToResponsive: any = createReactClass({
103
103
  const spacer = (
104
104
  <div
105
105
  style={{
106
- // $FlowFixMe[unsafe-addition]
107
106
  // @ts-expect-error [FEI-5003] - TS2362 - The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
108
107
  paddingBottom: (1 / aspectRatio).toFixed(4) * 100 + "%",
109
108
  }}
@@ -97,7 +97,6 @@ class Graph extends React.Component<any> {
97
97
  if (imageData.url) {
98
98
  const scale = this.props.box[0] / interactiveSizes.defaultBoxSize;
99
99
  image = (
100
- // $FlowFixMe[prop-missing]: `alt` is missing
101
100
  // @ts-expect-error [FEI-5003] - TS2741 - Property 'alt' is missing in type '{ src: any; width: any; height: any; scale: number; responsive: false; }' but required in type 'Pick<Readonly<Props> & Readonly<{ children?: ReactNode; }>, "children" | "height" | "width" | "title" | "alt" | "trackInteraction" | "preloader" | "allowFullBleed" | "extraGraphie" | "overrideAriaHidden">'.
102
101
  <SvgImage
103
102
  src={imageData.url}
@@ -118,13 +117,10 @@ class Graph extends React.Component<any> {
118
117
  width: this.props.box[0],
119
118
  height: this.props.box[1],
120
119
  }}
121
- // $FlowFixMe[prop-missing]: This can probably be removed
122
120
  // @ts-expect-error [FEI-5003] - TS2339 - Property 'onMouseOut' does not exist on type 'Graph'.
123
121
  onMouseOut={this.onMouseOut}
124
- // $FlowFixMe[prop-missing]: This can probably be removed
125
122
  // @ts-expect-error [FEI-5003] - TS2339 - Property 'onMouseOver' does not exist on type 'Graph'.
126
123
  onMouseOver={this.onMouseOver}
127
- // $FlowFixMe[prop-missing]: This can probably be removed
128
124
  // @ts-expect-error [FEI-5003] - TS2339 - Property 'onClick' does not exist on type 'Graph'.
129
125
  onClick={this.onClick}
130
126
  >
@@ -61,7 +61,9 @@ class HighlightingUI extends React.PureComponent<HighlightingUIProps> {
61
61
  }
62
62
  }
63
63
 
64
- _selectionIsValid(trackedSelection?: TrackedSelection | null): boolean {
64
+ _selectionIsValid(
65
+ trackedSelection?: TrackedSelection | null,
66
+ ): trackedSelection is TrackedSelection {
65
67
  if (!trackedSelection) {
66
68
  return false;
67
69
  }
@@ -123,22 +125,10 @@ class HighlightingUI extends React.PureComponent<HighlightingUIProps> {
123
125
  label={i18n._("Add highlight")}
124
126
  onClick={() =>
125
127
  this._handleAddHighlight(
126
- // TODO(mdr): We found a new Flow error when upgrading:
127
- // "proposedHighlight (Cannot get `trackedSelection.proposedHighlight` because property `proposedHighlight` is missing in null or undefined [1].)"
128
- // $FlowFixMe[incompatible-use](0.57.3->0.75.0)
129
- // @ts-expect-error [FEI-5003] - TS2533 - Object is possibly 'null' or 'undefined'.
130
128
  trackedSelection.proposedHighlight,
131
129
  )
132
130
  }
133
- // TODO(mdr): We found a new Flow error when upgrading:
134
- // "focusNode (Cannot get `trackedSelection.focusNode` because property `focusNode` is missing in null or undefined [1].)"
135
- // $FlowFixMe[incompatible-use](0.57.3->0.75.0)
136
- // @ts-expect-error [FEI-5003] - TS2533 - Object is possibly 'null' or 'undefined'.
137
131
  focusNode={trackedSelection.focusNode}
138
- // TODO(mdr): We found a new Flow error when upgrading:
139
- // "focusOffset (Cannot get `trackedSelection.focusOffset` because property `focusOffset` is missing in null or undefined [1].)"
140
- // $FlowFixMe[incompatible-use](0.57.3->0.75.0)
141
- // @ts-expect-error [FEI-5003] - TS2533 - Object is possibly 'null' or 'undefined'.
142
132
  focusOffset={trackedSelection.focusOffset}
143
133
  offsetParent={this.props.offsetParent}
144
134
  />
@@ -124,7 +124,7 @@ class SelectionTracker extends React.PureComponent<
124
124
  }
125
125
 
126
126
  // NOTE(mdr): The focus node is guaranteed to exist, because
127
- // there's a range, but the Flow type annotations for
127
+ // there's a range, but the type annotations for
128
128
  // Selection don't know that. Cast it ourselves.
129
129
  const focusNode: Node = selection.focusNode as any;
130
130
  const focusOffset = selection.focusOffset;
@@ -103,11 +103,7 @@ class WordIndexer extends React.PureComponent<WordIndexerProps> {
103
103
  let newTrailingWordRange = null;
104
104
  // @ts-expect-error [FEI-5003] - TS2345 - Argument of type 'string | null' is not assignable to parameter of type 'string'.
105
105
  while ((wordMatch = wordPattern.exec(text)) !== null) {
106
- // TODO(mdr): We found a new Flow error when upgrading:
107
- // "index (Cannot get `wordMatch.index` because property `index` is missing in null [1].)"
108
106
  const startOffset = wordMatch.index;
109
- // TODO(mdr): We found a new Flow error when upgrading:
110
- // "index (Cannot get `wordMatch.index` because property `index` is missing in null [1].)", "0 (Cannot get `wordMatch[0]` because an indexer property is missing in null [1].)"
111
107
  const endOffset = wordMatch.index + wordMatch[0].length;
112
108
 
113
109
  let range;
@@ -191,8 +191,6 @@ class MathInput extends React.Component<Props, State> {
191
191
  // close (blur) the button group in order to focus on next page element.
192
192
  if (
193
193
  !this.mouseDown &&
194
- // $FlowFixMe[incompatible-use]
195
- // $FlowFixMe[incompatible-call]
196
194
  // @ts-expect-error [FEI-5003] - TS2531 - Object is possibly 'null'.
197
195
  !ReactDOM.findDOMNode(this).contains(e.relatedTarget)
198
196
  ) {
@@ -110,8 +110,6 @@ class NumberInput extends React.Component<any, any> {
110
110
  */
111
111
  getValue: () => any = () => {
112
112
  return this.parseInputValue(
113
- // $FlowFixMe[incompatible-use]
114
- // $FlowFixMe[prop-missing]
115
113
  // @ts-expect-error [FEI-5003] - TS2531 - Object is possibly 'null'. | TS2339 - Property 'value' does not exist on type 'Element | Text'.
116
114
  ReactDOM.findDOMNode(this.refs.input).value, // eslint-disable-line react/no-string-refs
117
115
  );
@@ -116,8 +116,6 @@ class TextListEditor extends React.Component<any, any> {
116
116
  // eslint-disable-next-line react/no-string-refs
117
117
  // @ts-expect-error [FEI-5003] - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
118
118
  this.refs["input_" + focusIndex],
119
- // $FlowFixMe[incompatible-use]
120
- // $FlowFixMe[prop-missing]
121
119
  // @ts-expect-error [FEI-5003] - TS2339 - Property 'focus' does not exist on type 'Element | Text'.
122
120
  ).focus();
123
121
  });
@@ -156,8 +154,6 @@ class TextListEditor extends React.Component<any, any> {
156
154
  // eslint-disable-next-line react/no-string-refs
157
155
  // @ts-expect-error [FEI-5003] - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
158
156
  this.refs["input_" + focusIndex],
159
- // $FlowFixMe[incompatible-use]
160
- // $FlowFixMe[prop-missing]
161
157
  // @ts-expect-error [FEI-5003] - TS2339 - Property 'focus' does not exist on type 'Element | Text'.
162
158
  ).focus();
163
159
  });
@@ -26,10 +26,8 @@ const computeMathBounds = (
26
26
  parentNode.querySelector(".katex-html") ||
27
27
  parentNode.querySelector(".MathJax");
28
28
  const textBounds = {
29
- // $FlowFixMe[incompatible-use]
30
29
  // @ts-expect-error [FEI-5003] - TS2531 - Object is possibly 'null'. | TS2339 - Property 'offsetWidth' does not exist on type 'Element'.
31
30
  width: textElement.offsetWidth,
32
- // $FlowFixMe[incompatible-use]
33
31
  // @ts-expect-error [FEI-5003] - TS2531 - Object is possibly 'null'. | TS2339 - Property 'offsetHeight' does not exist on type 'Element'.
34
32
  height: textElement.offsetHeight,
35
33
  } as const;
@@ -63,12 +63,8 @@ class Zoomable extends React.Component<Props, State> {
63
63
  const firstChild = parentNode.firstElementChild;
64
64
 
65
65
  return {
66
- // $FlowFixMe[incompatible-use]
67
- // $FlowFixMe[prop-missing]
68
66
  // @ts-expect-error [FEI-5003] - TS2531 - Object is possibly 'null'. | TS2339 - Property 'offsetWidth' does not exist on type 'Element'.
69
67
  width: firstChild.offsetWidth,
70
- // $FlowFixMe[incompatible-use]
71
- // $FlowFixMe[prop-missing]
72
68
  // @ts-expect-error [FEI-5003] - TS2531 - Object is possibly 'null'. | TS2339 - Property 'offsetHeight' does not exist on type 'Element'.
73
69
  height: firstChild.offsetHeight,
74
70
  };
@@ -34,7 +34,6 @@ export class DefinitionProvider extends React.Component<
34
34
  };
35
35
 
36
36
  // Method to update state
37
- // $FlowFixMe[signature-verification-failure]
38
37
  setActiveDefinitionId = (activeDefinitionId?: string | null): void => {
39
38
  this.setState((prevState: ProviderState) => ({activeDefinitionId}));
40
39
  };
@@ -77,7 +77,7 @@ class HintsRenderer extends React.Component<Props, State> {
77
77
  this._cacheHintImages();
78
78
  }
79
79
 
80
- // Force number to make Flow happy
80
+ // Force number to make TypeScript happy
81
81
  const prevHintsVisible = prevProps.hintsVisible || 0;
82
82
  const nextHintsVisible = this.props.hintsVisible || 0;
83
83
 
@@ -53,7 +53,6 @@ describe("MovablePoint", function () {
53
53
  it("should snap to the grid when a snap is specified", function () {
54
54
  const point = createPoint({
55
55
  coord: [1.1, 1.1],
56
- // $FlowFixMe[prop-missing]
57
56
  // @ts-expect-error [FEI-5003] - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => void'.
58
57
  constraints: MovablePoint.constraints.snap([1, 1]),
59
58
  }).point;
@@ -174,10 +174,6 @@ class ItemRenderer extends React.Component<Props, State> {
174
174
  // strangeness instead of relying on React's normal render() method.
175
175
  // TODO(alpert): Figure out how to clean this up somehow
176
176
  reactRender(
177
- // metadata (from item.question, aka PerseusRenderer)
178
- // replace (also item.question, aka PerseusRenderer)
179
- // savedState (I _think_ this is serializedState on Renderer)
180
- // $FlowFixMe[prop-missing] metadata, replace, savedState (see above)
181
177
  <Renderer
182
178
  ref={(node) => {
183
179
  if (!node) {
@@ -293,7 +289,6 @@ class ItemRenderer extends React.Component<Props, State> {
293
289
  this.props.apiOptions.onFocusChange(
294
290
  this._currentFocus,
295
291
  prevFocus,
296
- // $FlowFixMe[incompatible-call]: onFocusChange expects an HTMLElement or nothing
297
292
  didFocusInput && keypadElement && keypadElement.getDOMNode(),
298
293
  );
299
294
  }
@@ -82,7 +82,7 @@ const _changeSingle = function (
82
82
  * this.change(propName) -> returns a lambda that takes a prop value to
83
83
  * set and a callback to call after having set that value.
84
84
  */
85
- // TODO(WEB-1727): use proper flow syntax for overloaded functions
85
+ // TODO(WEB-1727): use proper TypeScript syntax for overloaded functions
86
86
  export const change: ChangeFn = function (
87
87
  newPropsOrSinglePropName,
88
88
  propValue,
@@ -16,11 +16,8 @@ type Story = {
16
16
  export const SingleItem: React.FC<StoryArgs> = (args): React.ReactElement => {
17
17
  const item = {
18
18
  _multi: {
19
- // $FlowFixMe[not-an-object]
20
19
  ...question1._multi,
21
20
  blurb: {
22
- // $FlowFixMe[not-an-object]
23
- // $FlowFixMe[prop-missing]
24
21
  ...question1._multi.blurb,
25
22
  content:
26
23
  "This is a short snippet to help you understand the context of the question. We call it the 'blurb'.",
@@ -51,7 +48,6 @@ export const SingleItem: React.FC<StoryArgs> = (args): React.ReactElement => {
51
48
  </HeadingSmall>
52
49
  <View style={styles.hints}>
53
50
  {
54
- // $FlowFixMe[prop-missing]
55
51
  // @ts-expect-error [FEI-5003] - TS2339 - Property 'firstN' does not exist on type 'readonly ReactNode[]'.
56
52
  hints?.firstN(2)
57
53
  }
@@ -157,12 +157,8 @@ describe("inferItemShape", () => {
157
157
  /**
158
158
  * TODO(somewhatabstract, JIRA-XXXX):
159
159
  * The Tree types are really hard to work with properly.
160
- */
161
- // $FlowFixMe[incompatible-cast]
160
+ */ buildEmptyItemTreeForShape(shapes.hint),
162
161
  buildEmptyItemTreeForShape(shapes.hint),
163
- // $FlowFixMe[incompatible-cast]
164
- buildEmptyItemTreeForShape(shapes.hint),
165
- // $FlowFixMe[incompatible-cast]
166
162
  buildEmptyItemTreeForShape(shapes.hint),
167
163
  ] as ItemArrayNode);
168
164
  expect(shapes.arrayOf(shapes.hint)).toEqual(inferItemShape(item));
@@ -173,12 +169,8 @@ describe("inferItemShape", () => {
173
169
  /**
174
170
  * TODO(somewhatabstract, JIRA-XXXX):
175
171
  * The Tree types are really hard to work with properly.
176
- */
177
- // $FlowFixMe[incompatible-cast]
178
- buildEmptyItemTreeForShape(shapes.hint),
179
- // $FlowFixMe[incompatible-cast]
172
+ */ buildEmptyItemTreeForShape(shapes.hint),
180
173
  buildEmptyItemTreeForShape(shapes.content),
181
- // $FlowFixMe[incompatible-cast]
182
174
  buildEmptyItemTreeForShape(shapes.hint),
183
175
  ] as ItemArrayNode);
184
176
  expect(shapes.arrayOf(shapes.hint)).toEqual(inferItemShape(item));
@@ -214,9 +206,7 @@ const item: Item = treeToItem({
214
206
  /**
215
207
  * TODO(somewhatabstract, JIRA-XXXX):
216
208
  * The Tree types are really hard to work with properly.
217
- */
218
- // $FlowFixMe[incompatible-cast]
219
- b: [content(2), content(3), content(4)] as ItemArrayNode,
209
+ */ b: [content(2), content(3), content(4)] as ItemArrayNode,
220
210
  c: {
221
211
  d: content(5),
222
212
  e: hint(6),
@@ -580,7 +580,7 @@ describe("multi-item renderer", () => {
580
580
  // ("mock-widget 1"). This verifies that the MultiRenderer has
581
581
  // correctly passed down a functioning `findWidgets` prop to the
582
582
  // widgets.
583
- // Oh the Flow warnings we'll suppress. Welcome to multi items.
583
+ // Oh the TypeScript warnings we'll suppress. Welcome to multi items.
584
584
  const widget1 = result.question[0].props.findWidgets("mock-widget 1");
585
585
 
586
586
  // Assert
@@ -6,7 +6,7 @@ import shapes from "../shapes";
6
6
  // tests. Rewrite them once we're using the prop-types library.
7
7
  describe.skip("buildPropTypeForShape", () => {
8
8
  // The value we're wrapping might not be a valid ItemTree - that's the
9
- // point of testing this PropType - so we disable Flow checking by casting
9
+ // point of testing this PropType - so we disable type checking by casting
10
10
  // `value` to type `any`. The current implementation of `treeToItem` can
11
11
  // handle that possibility.
12
12
  const tryPropType = (propType: any, value: any) =>
@@ -26,13 +26,13 @@ describe("buildMapper", () => {
26
26
  }
27
27
 
28
28
  function tags(...elements): TagsNode {
29
- // This function mostly exists as a shorthand way to clarify to Flow
29
+ // This function mostly exists as a shorthand way to clarify to TypeScript
30
30
  // that this is a TagsNode, not a confused ItemArrayNode.
31
31
  return elements;
32
32
  }
33
33
 
34
34
  function array(...elements): ItemArrayNode {
35
- // This function mostly exists as a shorthand way to clarify to Flow
35
+ // This function mostly exists as a shorthand way to clarify to TypeScript
36
36
  // that this is an ItemArrayNode, not a confused TagsNode.
37
37
  /**
38
38
  * TODO(somewhatabstract, JIRA-XXXX):
@@ -288,18 +288,10 @@ describe("buildMapper", () => {
288
288
 
289
289
  it("uses the array mapper return value to construct the new tree", () => {
290
290
  const mapper = buildMapper()
291
- // $FlowFixMe[not-a-function]
292
- // $FlowFixMe[prop-missing]
293
- // $FlowFixMe[incompatible-use]
294
291
  // @ts-expect-error [FEI-5003] - TS2571 - Object is of type 'unknown'.
295
292
  .setContentMapper((c) => c.content)
296
- // $FlowFixMe[not-a-function]
297
- // $FlowFixMe[prop-missing]
298
- // $FlowFixMe[incompatible-use]
299
293
  // @ts-expect-error [FEI-5003] - TS2571 - Object is of type 'unknown'.
300
294
  .setHintMapper((h) => h.content)
301
- // $FlowFixMe[not-a-function]
302
- // $FlowFixMe[prop-missing]
303
295
  // @ts-expect-error [FEI-5003] - TS2571 - Object is of type 'unknown'.
304
296
  .setTagsMapper((t) => t.join(", "))
305
297
  .setArrayMapper((mappedArray, originalArray, shape, path) => {
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable react/no-unsafe */
2
- // TODO(mdr): There are some Flow errors in this file, and they're tricky, so
3
- // I'm skipping Flow errors for now.
2
+ // TODO(mdr): There are some TypeScript errors in this file, and they're tricky, so
3
+ // I'm skipping TypeScript errors for now.
4
4
  /**
5
5
  * Main entry point to the MultiRenderer render portion.
6
6
  *
@@ -36,9 +36,8 @@
36
36
  * </MultiRenderer>
37
37
  */
38
38
  import * as i18n from "@khanacademy/wonder-blocks-i18n";
39
- import {StyleSheet, css} from "aphrodite";
40
- // eslint-disable-next-line import/no-extraneous-dependencies
41
- import lens from "hubble";
39
+ import {StyleSheet, css} from "aphrodite"; // eslint-disable-line import/no-extraneous-dependencies
40
+ import lens from "hubble"; // eslint-disable-line import/no-extraneous-dependencies
42
41
  import * as React from "react";
43
42
 
44
43
  import HintsRenderer from "../hints-renderer";
@@ -87,7 +86,7 @@ type RendererDataTree = Tree<ContentRendererData, HintRendererData, null>;
87
86
 
88
87
  /**
89
88
  * TODO(somewhatabstract, JIRA-XXXX):
90
- * Some usage of this type somewhere is causing Flow to believe that these
89
+ * Some usage of this type somewhere is causing TypeScript to believe that these
91
90
  * elements should be components. Don't know where that is, to fix it up
92
91
  * properly. In reality, these types are just too hard to use and aren't
93
92
  * really helping us out as I now have to suppress this rather than
@@ -245,7 +244,7 @@ class MultiRenderer extends React.Component<Props, State> {
245
244
  // were to change every render, it would cause the Renderer to
246
245
  // re-render a lot more than is necessary. Don't re-compute this
247
246
  // element unless it is necessary!
248
- // HACK(mdr): Flow can't prove that this is a ContentRendererData,
247
+ // HACK(mdr): TypeScript can't prove that this is a ContentRendererData,
249
248
  // because of how we awkwardly construct it in order to obtain a
250
249
  // circular reference. But it is, I promise.
251
250
  const data: any = {ref: null, makeRenderer: null};
@@ -264,9 +263,7 @@ class MultiRenderer extends React.Component<Props, State> {
264
263
  * if this spread is including undocumented props so mapping
265
264
  * one to one could introduce a bug. Need to work out the exact
266
265
  * type for ContentNode and then fix this.
267
- */
268
- // $FlowFixMe[cannot-spread-inexact]
269
- // @ts-expect-error [FEI-5003] - TS2322 - Type '{ ref: (e: any) => any; findExternalWidgets: (criterion: any) => readonly (Widget | null | undefined)[]; serializedState: any; onSerializedStateUpdated: (state: any) => void; __type: "content" | "item"; ... 9 more ...; reviewMode?: boolean | ... 1 more ... | undefined; }' is not assignable to type 'InexactPartial<Pick<Readonly<Props> & Readonly<{ children?: ReactNode; }>, "content" | "images" | "onRender" | "linterContext" | "widgets" | "alwaysUpdate" | ... 6 more ... | "serializedState">>'.
266
+ */ // @ts-expect-error [FEI-5003] - TS2322 - Type '{ ref: (e: any) => any; findExternalWidgets: (criterion: any) => readonly (Widget | null | undefined)[]; serializedState: any; onSerializedStateUpdated: (state: any) => void; __type: "content" | "item"; ... 9 more ...; reviewMode?: boolean | ... 1 more ... | undefined; }' is not assignable to type 'InexactPartial<Pick<Readonly<Props> & Readonly<{ children?: ReactNode; }>, "content" | "images" | "onRender" | "linterContext" | "widgets" | "alwaysUpdate" | ... 6 more ... | "serializedState">>'.
270
267
  <Renderer
271
268
  {...this._getRendererProps()}
272
269
  {...content}
@@ -2,7 +2,7 @@
2
2
  * Utility functions to build React PropTypes for multi-items and shapes.
3
3
  *
4
4
  * If you're writing new components, though, consider using the Item and Shape
5
- * Flow types instead.
5
+ * types instead.
6
6
  */
7
7
  /* instanbul ignore file */
8
8
 
@@ -11,7 +11,7 @@
11
11
  * Shapes also enable us to traverse a multi-item-shaped tree with confidence,
12
12
  * even when we can't infer the shape from the tree alone.
13
13
  *
14
- * We *could* go all-in on a more general library to make certain Flow types
14
+ * We *could* go all-in on a more general library to make certain types
15
15
  * runtime-inspectable, in order to DRY some things up, but that's probably a
16
16
  * big ol' infrastructural magic mess, and the narrower scope of Shapes makes
17
17
  * it easier to be confident that we've covered all cases rather than having to
@@ -34,7 +34,7 @@ export type ObjectNode<C, H, T> = {
34
34
  * TODO(somewhatabstract, JIRA-XXXX):
35
35
  * We should ditch this type or create some helpers for working with it.
36
36
  * As it stands, consumers have to check each node's type before using it
37
- * in order to ensure that flow can track its refinement and appropriate use.
37
+ * in order to ensure that TypeScript can track its refinement and appropriate use.
38
38
  * It's messy.
39
39
  */
40
40
  // @ts-expect-error [FEI-5003] - TS2456 - Type alias 'Tree' circularly references itself. | TS2315 - Type 'ArrayNode' is not generic.