Convert to TypeScript and ensure strict type safety #101
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.
Overview
Inspired by PR #98 and #99, and with the desire to use Typia functions which means types must be properly defined, I have ported all the JS functions to fully typed TS.
The only function signature change is in
src/utils.ts
, where thehasOwnProperty
method expects a PropertyKey parameter, so I updated the function to expect that type only.No other function signatures are changed.
The benefit is that for all functions, TS users have a reliable type output based on the types supplied as inputs. No change to JS users.
Ensured that
build
,lint
,test
, andtest:coverage
all pass without errors. Replacedyarn
commands withnpm
asyarn
was not specified as adevDependency
.Types
The main types returned by the various diff functions are now defined as follows:
The types were determined by reading the function code and ensuring the returned values match the specified type.