Skip to content

feat(cli): publish TypeScript declarations - #134

Merged
Donny/강동윤 (kdy1) merged 1 commit into
swc-project:mainfrom
SimenB:include-types
Aug 31, 2026
Merged

Donny/강동윤 (kdy1) merged 1 commit into
swc-project:mainfrom
SimenB:include-types

Conversation

@SimenB

Copy link
Copy Markdown
Contributor

@swc/cli ships no type declarations today, so import { swcDir } from "@swc/cli" resolves to any for TypeScript consumers. The published tarball does, on the other hand, contain the compiled test and mock files.

tsc now emits declarations, and package.json points types at lib/swc/index.d.ts.

include still covers all of src, so test and mock files keep getting typechecked on every build. They compile into lib/ as before, but two negated patterns in files keep them out of the tarball:

"files": ["bin", "lib", "!lib/**/__tests__", "!lib/**/__mocks__"]

Verification

npm pack --dry-run reports 32 files, 13 of them .d.ts, and no __tests__ or __mocks__ entry. A control run with the two negated patterns removed reports 46 files, 14 of them test or mock — which is what the package publishes today.

A scratch consumer importing swcDir from the emitted lib/swc/index.d.ts typechecks clean under strict without chokidar installed. The chokidar type references live in sources.d.ts, which the public entry chain never reaches.

tsc is clean and all 37 tests pass.

tsc now emits declaration files, and package.json points at them. The
compiled test and mock files are excluded from the tarball, so they are
still typechecked on every build but no longer published.
@changeset-bot

changeset-bot Bot commented Aug 28, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 93ec209

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@swc/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@kdy1
Donny/강동윤 (kdy1) merged commit 2cbd470 into swc-project:main Aug 31, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants