This repository was archived by the owner on Feb 9, 2024. It is now read-only.
Export all needed types via dist/index.d.ts
#106
Merged
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.
In order to publish types, the minimal change required is:
index.tsto also exportOptions, CacheControl, MethodNotAllowedError, NotFoundError, InternalErrornpm run build(which runstsc -d, where the-dflag indicates togenerate type definition files)
I observed that this generates a
dist/index.d.tstype definition file thatcontains all types except those defined in
src/mock.ts, which are onlyrequired for package tests and thus don’t need to be published.
package.jsonalready specifies these as the package’s types:As a side note, I’m not sure why
index.d.ts(even with a subset of types)isn’t included in the
0.0.10release. If I check out thev0.0.10tag and runnpm publish —dry-runI observe that it includesdist/index.d.tsin thepackage. However, that file is not present in the built package from npm.
Finally, I tested that this works using
npm link– reviewers can play alongtoo if you like. First, in this branch of
kv-asset-handler, runnpm link.Then, I created a new typescript project containing the updated sample code
from @kentonv’s PR against
README.mdin #102, then ran:This symlinks to the local copy of
kv-asset-handlerinstead of the 0.0.10release on npm. After doing so, I was able to do the following in said new
project:
I validated that the new example code transpiles when using these typings.