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 enables users to install replugged using the git syntax that npm allows. There 2 parts to the PR - the type changes & the script changes. Neither change the replugged API.
The type changes are a bit odd. These are required to make the package 'portable'. This is an issue thats tracked on the ts repo. The workaround implemented here is a based on this comment, but instead of creating an intermediate interface, we re-export the React namespace as _. The exported
_
isn't intended for actual use, the idea is that it can be an unlinted unused type import, but be there enough so that typescript still correctly identifies the react types. Also yeah - i did check if its possible to just not import the_
but I couldn't find a way to not. It shouldn't affect anything at all since its exported as a type and its a namespace anyways.TLDR is that typescript is weird & this is a non-intrusive way to make it just work.
The second part of this is the script changes. I aliased the current prepublishOnly script to be build:types as it makes a bit more sense it terms of naming and clarity, especially since its reused. I then removed the prepublishOnly script in favor of the prepare script, as its a ran post install & pre publish. For compatibility with npm it first does a check to see if src present. If it ain't present, its an npm pkg & therefore doesn't need any to have it's types built.
As for why this is needed - primarily its for testing & preparing for new releases. Secondary, it makes the code more 'correct' since its able to compile in more contexts.