Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port utils to @flow. #935

Merged
merged 3 commits into from
Oct 15, 2017
Merged

Port utils to @flow. #935

merged 3 commits into from
Oct 15, 2017

Conversation

marcianx
Copy link
Collaborator

No description provided.

src/utils.js Outdated
return indexOf(list, elem) !== -1;
};

/**
* Provide a default value if a setting is undefined
*/
const deflt = function(setting, defaultIfUndefined) {
const deflt = function<T>(setting: T | void, defaultIfUndefined: T): * {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment with a link to the issue?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

src/utils.js Outdated
return indexOf(list, elem) !== -1;
};

/**
* Provide a default value if a setting is undefined
*/
const deflt = function(setting, defaultIfUndefined) {
const deflt = function<T>(setting: T | void, defaultIfUndefined: T): * {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment with a link to the issue?

src/utils.js Outdated
@@ -55,18 +56,16 @@ const ESCAPE_LOOKUP = {

const ESCAPE_REGEX = /[&><"']/g;

function escaper(match) {
// Type-safe only if the input string matches ESCAPE_REGEX.
function escaper(match: string): string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's possible that escaper could return undefined.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not given the comment I'd added above escaper(). It's used only for escape(). In fact, I removed this function and just inlined it where it's used.

src/utils.js Outdated
@@ -27,21 +28,21 @@ const indexOf = function(list, elem) {
/**
* Return whether an element is contained in a list
*/
const contains = function(list, elem) {
const contains = function<T>(list: Array<T>, elem: T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return value for this could be boolean.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops. I wish flow would catch missing types.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes please!

Copy link
Member

@kevinbarabash kevinbarabash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kevinbarabash kevinbarabash merged commit ca5a924 into KaTeX:master Oct 15, 2017
@marcianx marcianx deleted the flow-utils branch October 15, 2017 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants