Skip to content

build: type the ./css subpath export (drop the @ts-expect-error)#41

Open
ryankiley wants to merge 1 commit into
mainfrom
fix/css-subpath-types
Open

build: type the ./css subpath export (drop the @ts-expect-error)#41
ryankiley wants to merge 1 commit into
mainfrom
fix/css-subpath-types

Conversation

@ryankiley

@ryankiley ryankiley commented Jun 14, 2026

Copy link
Copy Markdown
Owner

Found while integrating tweakit into a Nuxt + vue-tsc app.

Problem

Importing the stylesheet via the subpath export —

import "tweakit/css";

— raised TS2307: Cannot find module 'tweakit/css'. A bare package-subpath import isn't matched by a global *.css ambient, and the ./css export had no types condition, so consumers needed a @ts-expect-error.

Fix (packaging only — source unchanged)

  • The build emits a tiny side-effect dist/tweaks.css.d.ts (export {};).
  • The ./css export gains a types condition pointing at it; files ships it (109 B).

Verify

  • import "tweakit/css" now resolves cleanly under --moduleResolution bundler (what Nuxt/vue-tsc use) — no @ts-expect-error.
  • npm test 28/28; declaration present in the published tarball.

Note: the only other DX nit encountered — building a schema object and passing it to tweaks() needing an as Schema cast — turned out to be consumer-side: typing the builder with the already-exported SchemaObject / Schema removes the cast, so no kit change is warranted there.

A TS consumer importing the stylesheet via the subpath —
  import "tweakit/css";
— hit TS2307: a bare package-subpath import isn't matched by a global
*.css ambient, and the ./css export had no types condition. Emit a tiny
side-effect dist/tweaks.css.d.ts and give ./css a types condition so the
subpath resolves with no @ts-expect-error. Packaging only; source unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant