Repository navigation
fix: emit non-empty types for nativewind/preset - #1784
Open
TheSeydiCharyyev wants to merge 1 commit into
Open
TheSeydiCharyyev wants to merge 1 commit into
TheSeydiCharyyev wants to merge 1 commit into
Conversation
The source file used `module.exports = Object.assign(...)` which TypeScript's declaration emit can't generate types for, so the published package shipped an empty `dist/tailwind/index.d.ts`. Users importing `nativewind/preset` under `checkJs: true` hit TS2306. Switch to `const preset = Object.assign(...); export = preset;`. This pattern is correctly handled by `tsc --declaration` (emits a non-empty .d.ts), compiles to the same `module.exports = preset` runtime shape, and preserves the callable-with-property API — no breaking change for consumers. Fixes nativewind#1330
This branch has not been deployed
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.
Summary
Fixes #1330.
packages/nativewind/src/tailwind/index.tsusesmodule.exports = Object.assign(...), a pattern TypeScript's declaration emit can't handle — the published package ships an emptydist/tailwind/index.d.ts. Users importingnativewind/presetundercheckJs: true(or from*.tsfiles) hitTS2306: File '.../dist/tailwind/index.d.ts' is not a module.@danstepanov confirmed the root cause in #1330 (comment):
Fix
Switch to the canonical TS-compatible CJS pattern:
tsc --declarationemits a non-empty.d.tsforexport = X..jsstill emitsmodule.exports = preset— identical runtime shape, no breaking change for consumers.as constnarrowsnativewind: trueto a literal type, matching the manual workaround users have been writing via module augmentation.Verification
Before fix:
dist/tailwind/index.d.tsis 0 bytes.After fix:
dist/tailwind/index.d.tscontains:Compiled
dist/tailwind/index.jsis runtime-equivalent (module.exports = presetwith the same callable +nativewind: trueproperty).Tests
npm testpasses — 784/784 tests across 30 suites, no regressions.