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.
I've been working on this for a while! It has been a very fun though hard challenge. Want to thank @fivitti for his feedbacks ;-)
resolves #24
Tested and linted typescript definitions for TS ⩾ 3.5.
Highlights
The root of typings are in types/patchinko, a requirement from dtslint.
The most important tests are located in
__tests__/explicit
and__tests__/overlaoded
.One big feature of those typings is to strictly enforce patchinko rules. As such, every do and don't from the readme has been carefuly tested and implemented.
Example with
__tests__/overlaoded
:__tests__/explicit
:Limitations
One limitation of those types however, is that the returned type of a
P(target, ...)
call will always betypeof target
. Although it could be possible, in theory, to find the resulting type from operations such as deletions ore scoped replacements, I have found this incredibly difficult and wasn't certain the compiler could follow this level of complexity and computational burden. Therefore, I thought it would be an acceptable compromise to return the target type, given the vast majority of use-cases where one want such outcome.One who needs to circumvent those limitations just has to cast patch target to unknown:
Testing
Run tests with
npm run test:ts
which uses dtslint in the background.It does the following: