Skip to content

Commit

Permalink
Fix propUpgrades type and some numeric-input option types that aren't…
Browse files Browse the repository at this point in the history
… matched to the implementation
  • Loading branch information
jeremywiebe committed Mar 24, 2023
1 parent f5e85a1 commit 5202dd6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
13 changes: 8 additions & 5 deletions packages/perseus/src/perseus-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -725,8 +725,9 @@ export type PerseusNumericInputWidgetOptions = {|
answers: $ReadOnlyArray<PerseusNumericInputAnswer>,
// Translatable Text; Text to describe this input. This will be shown to users using screenreaders.
labelText: string,
// Use size "Normal" for all text boxes, unless there are multiple text boxes in one line and the answer area is too narrow to fit them. Options: "normal" or "small"
size: string,
// Use size "Normal" for all text boxes, unless there are multiple text boxes in one line and the answer area is too narrow to fit them.
// Options: "normal" or "small"
size: "normal" | "small",
// A coefficient style number allows the student to use - for -1 and an empty string to mean 1.
coefficient: boolean,
// Whether we're asking for all correct solutions or only one
Expand All @@ -750,16 +751,18 @@ export type PerseusNumericInputAnswer = {|
value: number,
// Whether this answer is "correct", "wrong", or "ungraded"
status: string,
// The forms available for this answer. Options: "integer, ""decimal", "proper", "improper", "mixed", or "pi"
// The forms available for this answer.
// Options: "integer, ""decimal", "proper", "improper", "mixed", or "pi"
// NOTE: perseus_data.go says this is required even though it isn't necessary.
answerForms?: $ReadOnlyArray<MathFormat>,
// Whether the answerForms should be strictly matched
strict: boolean,
// A range of error +/- the value
// NOTE: perseus_data.go says this is non-nullable even though we handle null values.
maxError: ?number,
// Unsimplified answers are Ungraded, Accepted, or Wrong. Options: "required", "correct", or "enforced"
simplify: ?string,
// Unsimplified answers are Ungraded, Accepted, or Wrong.
// Options: "required", "correct", or "enforced"
simplify: ?("required" | "optional" | "enforced"),
|};

export type PerseusNumberLineWidgetOptions = {|
Expand Down
14 changes: 13 additions & 1 deletion packages/perseus/src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,19 @@ export type WidgetExports<
tracking?: Tracking,
staticTransform?: WidgetTransform, // this is a function of some sort
traverseChildWidgets?: $FlowFixMe, // (Props, traverseRenderer) => NewProps
propUpgrades?: {|[string]: ($FlowFixMe) => $FlowFixMe|}, // OldProps => NewProps
// propUpgrades is a map! The key is the _target_ major version as a string
// (so '1' for major version 1). THe value is a transform function that
// takes the props from the previous version and migrates them to target
// version-compatible props. See the radio.jsx widget for an example.
// Minor version upgrades are not represented here. Instead, the upgrade
// machinery fills in any new props in a minor version with their default
// value as defined by the editor widget's `defaultProps` value for each
// widget.
propUpgrades?: {|
[targetMajorVersion: string]: (
previousMajorVersionProps: $FlowFixMe,
) => $FlowFixMe,
|}, // OldProps => NewProps
widget: T,
|}>;

Expand Down

0 comments on commit 5202dd6

Please sign in to comment.