Change our js/ts/npm build config to get types working in downstream projects #78
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 was a journey. And I've had some journeys with JS. I hope it's
over. But I'm definitely playing with fire here.
The goal: when you use skdb as a dependency in a downstream project,
you don't get any typing info other than for the one exported function
defined in skdb.ts. I wanted to fix this.
I tried a lot of things, but eventually found compiler and npm config
that works and is recommended by the typescript documentation.
https://www.typescriptlang.org/docs/handbook/modules/guides/choosing-compiler-options.html#im-writing-a-library
I had to make a lot of adjustments to how we define imports/exports to
make typescript happy under this new config. Which then broke what
sknpm produces, so I fixed that.
Something to note -- which sknpm was already taking care of, so I left
well alone -- is that using paths in libraries is bad and we should
make sure they never leak out in to the deliverable. They are not
re-written by the compiler and require all downstream libraries to
define them. Complete insanity.
https://stackoverflow.com/a/52501384
microsoft/TypeScript#15479
I'm somewhat confident this works and is correct, but it's JS and
there are many many permutations of env, so who knows?