Skip to content

Ship types for the /prettier export (fixes ts7016 in TS consumers)#47

Merged
kpal81xd merged 1 commit into
mainfrom
feat/prettier-export-types
Jun 3, 2026
Merged

Ship types for the /prettier export (fixes ts7016 in TS consumers)#47
kpal81xd merged 1 commit into
mainfrom
feat/prettier-export-types

Conversation

@kpal81xd

@kpal81xd kpal81xd commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Summary

TS consumers of @playcanvas/eslint-config/prettier — e.g. a typed prettier.config.mjs like vscode-extension's (playcanvas/vscode-extension#304) — hit:

ts(7016): Could not find a declaration file for module '@playcanvas/eslint-config/prettier'

because the package shipped no type declarations. This ships types for the /prettier export.

Changes

  • types/prettier.d.ts (new, hand-written) and the export becomes:
    "./prettier": { "types": "./types/prettier.d.ts", "default": "./dist/configs/prettier.js" }
    Hand-written (not tsc-emitted) because the eslint configs can't emit portable declarations — typescript-eslint's composed flat-config types trip TS2742 ("inferred type cannot be named"). The Prettier config is a simple object, so a small declaration covers it. This is why only /prettier ships types for now.
  • package.jsonfiles now includes types.
  • tsconfig.jsonexclude adds types (the hand-written .d.ts isn't a tsc input).
  • eslint.config.mjs (repo's own) — ignores types/: @typescript-eslint/unified-signatures crashes on the ambient .d.ts (TypeError: typeParameters.params is not iterable), and Prettier already formats it. Shared config unchanged.
  • src/configs/typescript.ts — blank line above the eslint-config-prettier comment (readability; matches vscode-extension).

Verification (clean-room A/B)

WITH the shipped .d.ts:   tsc --strict on `import config from '@playcanvas/eslint-config/prettier'` → exit 0 ✓
WITHOUT it (control):     → error TS7016 (reproduces the bug)

Plus npm run lint / npm test / npm run publint all green.

Rollout

Ships in 3.0.0-beta.3. After publish, vscode-extension's prettier.config.mjs squiggle clears once it bumps to beta.3 (no code change needed there).

Known limitation

The /typescript, /legacy, /react exports still ship no types (same TS2742 blocker). A consumer importing those in a type-checked context could see ts(7016); flat eslint configs are usually .mjs excluded from tsc, so this is rarely hit. Typing those would need explicit annotations on the config arrays — out of scope here.

TS consumers of @playcanvas/eslint-config/prettier (e.g. a typed
prettier.config.mjs, like vscode-extension's) hit `ts(7016): Could not find a
declaration file` because the package shipped no types.

- add types/prettier.d.ts (hand-written) and wire the export as
  { "types": "./types/prettier.d.ts", "default": "./dist/configs/prettier.js" }.
  The eslint configs can't emit declarations (typescript-eslint's composed types
  aren't portable — TS2742), so only this simple config ships types.
- files: add "types"; tsconfig: exclude types/; repo eslint ignores types/
  (@typescript-eslint/unified-signatures crashes on ambient .d.ts; prettier still
  formats it)
- typescript.ts: blank line above the eslint-config-prettier comment

Verified in a clean-room TS project: importing /prettier type-checks (tsc exit
0); removing the .d.ts reproduces ts7016. Ships in 3.0.0-beta.3.
@kpal81xd kpal81xd merged commit 28146d7 into main Jun 3, 2026
3 checks passed
@kpal81xd kpal81xd deleted the feat/prettier-export-types branch June 3, 2026 10:35
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