-
Notifications
You must be signed in to change notification settings - Fork 350
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KAS: try to type some things (#1449)
* make parser-generator ts * make compare happy with types * add return type for compare * move index to ts * undo that * changeset * respond to Jeremys feedback
- Loading branch information
Showing
5 changed files
with
54 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@khanacademy/kas": patch | ||
--- | ||
|
||
Add some types to the KAS package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 12 additions & 15 deletions
27
packages/kas/src/compare.js → packages/kas/src/compare.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
export type CompareOptions = { | ||
// Check that the two expressions have the same form | ||
form: boolean; | ||
// Check that the second expression is simplified | ||
simplify: boolean; | ||
}; | ||
|
||
export type CompareResult = { | ||
equal: boolean; | ||
wrongVariableCase?: boolean; | ||
wrongVariableNames?: boolean; | ||
message: string | null; | ||
}; | ||
|
||
export type ExpressionVars = { | ||
equal: boolean; | ||
equalIgnoringCase: boolean; | ||
}; | ||
|
||
export type Expression = { | ||
compare: (expr: Expression) => boolean; | ||
sameVars: (expr: Expression) => ExpressionVars; | ||
sameForm: (expr: Expression) => unknown; | ||
isSimplified: () => boolean; | ||
}; |