Typescript Support #27
Open
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 addresses #25 by adding typescript support to the project.
This PR also fixes webpack support mentioned in #15, bringing the number of open issues down to 0 if this is merged!
This shouldn't hinder the developers of the library and has a relatively low learning curve. Some things were changed from functions that return a "module" to classes with a constructor. This is functionally the same pattern and more standard, so use doesn't change much, if at all.
Most function signatures remain unchanged aside from getSott, which before was under the helper object in the loginradius function. Now it is directly exposed from the login radius API instead. This is a very small change in the code of users that use this function(lrv2.helper.getSott becomes lrv2.getSott). Additionally if they are using an IDE, this should show up in the editor and should be fairly obvious how to fix it. The README has been updated to accommodate this small change as well.
This PR adds a build script and prepublish that would run automatically when the library is published to npm, so there is no complicated process to learn or tweak in order to work with this. Just publish as you usually would and the script will handle the rest.
This PR didn't add any types for returns. The return types of the functions isn't immediately clear to me and would take a substantial amount of time. I'm sure another community member would be happy to do this, or someone at the loginradius team.
Lastly, this PR adds support for ESM as well as CJS by building both. This will ensure this library is compatible with both old and new nodejs versions and different environments.
Please let me know your thoughts! I put quite a bit of time into this PR since we intend to use it at my workplace and wished to share the code with the community.