Point the npm package's types at the declarations Kotlin/JS emits - #431
Open
holodorum wants to merge 1 commit into
Open
Point the npm package's types at the declarations Kotlin/JS emits#431holodorum wants to merge 1 commit into
holodorum wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The generated
package.jsonadvertised./kson-kson-lib.d.tsat the package root. That file was never in the tarball: Kotlin/JS emits.d.mtsbeside each module, and the copy step meant to hoist declarations to the root matched*.d.ts, so it silently copied nothing.Under
moduleResolution: nodenextthis went unnoticed — thenodecondition matches first and TypeScript falls back to the sibling.d.mts. Underbundlerresolution, the Vite and Next.js default, it failed outright:So the published package had no usable types for anyone resolving that way.
The fix
Each export condition now names the declarations sitting beside the module it resolves to, with
typeslisted first so it is reachable — Node and TypeScript take the first matching key within a condition, and atypesentry afterdefaultis never read.The
defaultcondition is load-bearing rather than boilerplate:bundlerresolution uses the conditions["types", "import"], which match neitherbrowsernornode, so without it those projects still fail to resolve.Also corrects the README's TypeScript example, which imported from
ksonrather than@kson_org/ksonand so could not resolve, and the-Prelease=truemissing from the documented build step.