Repository navigation
fix: publish declarations that resolve under NodeNext - #216
Merged
Merged
Conversation
The adapters compiled with moduleResolution bundler, so relative imports in src had no extension and tsc copied them into the published .d.ts files. Consumers on NodeNext or Node16 could not resolve them and every exported function typed as any, hidden by skipLibCheck. - Add explicit .js extensions to every relative import in express, fastify and nextjs, and compile those packages with NodeNext like core already does, so a missing extension fails the build with TS2835. The emitted JavaScript is byte-identical. - Move @types/jsonwebtoken to core's dependencies, since core's public declarations import JwtPayload from jsonwebtoken. - Run every package's consumerTypes test with skipLibCheck off under bundler and NodeNext, and assert real function types with @ts-expect-error on wrong calls, which fails if an export degrades to any. Add the test to core and nextjs. - Refresh zod in the lockfile to 4.6.5. @seamless-auth/types 0.28.0 declarations need the two-argument ZodPreprocess, which zod 4.4.3 lacks. Closes #214
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.
Closes #214
Problem
@seamless-auth/express,@seamless-auth/fastifyand@seamless-auth/nextjscompiled withmoduleResolution: "bundler", so relative imports insrcwere extensionless and tsc copied them verbatim into the published.d.ts. NodeNext and Node16 consumers cannot resolve those, sorequireAuth,createSeamlessAuthHandler,getSeamlessSessionand the rest typed asany.skipLibCheck: truehid it.Core was already NodeNext with
.jsextensions, but its declarations importJwtPayloadfromjsonwebtokenwhile@types/jsonwebtokenwas only a dev dependency, so consumers without their own copy got TS7016 (and ananypayload).All four packages are ESM only (
exportshastypes+import, norequirecondition), so no.d.ctsis needed.Fix
.jsextensions to all 220 relative imports in the three adapters, and compile them withmodule/moduleResolution: "NodeNext"like core. A missing extension now failsbuild:typeswith TS2835, so no separate lint is needed.@types/jsonwebtokeninto core'sdependencies.consumerTypestests: run with--skipLibCheck falseunderbundlerandNodeNextfor all four packages (new for core and nextjs). Each fixture has@ts-expect-erroron wrong calls (requireAuth(42),createSeamlessAuthHandler(42),getSeamlessSession(42),verifyCookieJwt(42),loginHandler(42)from@seamless-auth/core/handlers/login, ...). If an export degrades toany, the directive is unused and tsc fails.skipLibCheckoff,@seamless-auth/types@0.28.0declarations use the two-argumentZodPreprocess, which 4.4.3 lacks (TS2707). That is a too-low zod floor in@seamless-auth/types(^4.3.6), worth fixing there separately.Emitted JavaScript is unchanged: diffing the packed tarballs before and after, only
.d.ts,.d.ts.mapand core'spackage.jsondiffer.Reproduction (packed tarballs, scratch consumer)
pnpm packof each package, installed into a scratch project with"module": "NodeNext","moduleResolution": "NodeNext","strict": true,"skipLibCheck": false:Before (origin/main)
skipLibCheck: false: 26 errors. 23 x TS2834 in the adapters (7 express, 9 fastify, 7 nextjs), 2 x TS7016 in core, for example:skipLibCheck: true: only the core call is flagged. The four wrong adapter calls pass, because the exports areany:After
skipLibCheck: falseandtruegive the same output, no library errors, and every wrong call is flagged:(After run uses
@types/node@24to match.nvmrc. With@types/node@26, fastify's transitivethread-stream@4.2.0declarations fail onTransferListItem, which is unrelated to this repo and was only invisible before because fastify's own types never loaded.)Runtime import of all four packed packages from the consumer still works.
consumerTypes tests
New fixtures against the old source (
skipLibCheckoff):@ts-expect-error)After the fix, all 8 pass.
arethetypeswrong (
attw --pack --profile esm-only)The remaining
CJSResolvesToESMnote is expected: the packages are ESM only.Checks
pnpm build: passespnpm test: core 410, express 213, fastify 169, nextjs 168, all passingNo public API change; no cross-repo impact on
seamless-auth-apior the SDKs.