Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR consists of two parts so they can be reverted if you want to.
Fixed some bugs highlighted by static analyzers
Corrected some errors/warns highlighted by ESLint and TypeScript. These changes partially overlap with #51.
I've used these configs (not included to PR)
jsconfig.json
.eslintrc.json
Added JSDoc type annotations for output values
I've added type annotation for class properties and some function arguments so return types of exported functions (like
parseARule()
) can now be inferred.This may be very useful, for example, in this code:
a editor with enabled TypeScript features (such as VSCode) will suggest that
comp
has atype
property with one of predefined values ("BLOCK", "IDENT", "FUNCTION", ...) and insideif
condition thecomp
type will be narrowed down toFunc
with stringname
and arrayvalue
.For simplicity, arguments of exported functions and some of the internal code is not type annotated.
while(1) loops are now while(true) because "1" is not an "endless" condition for TS
This function return type will be
number | undefined
, but withwhile(true)
the type will benumber
as expected: