Ship types for the /prettier export (fixes ts7016 in TS consumers)#47
Merged
Conversation
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.
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
TS consumers of
@playcanvas/eslint-config/prettier— e.g. a typedprettier.config.mjslike vscode-extension's (playcanvas/vscode-extension#304) — hit:because the package shipped no type declarations. This ships types for the
/prettierexport.Changes
types/prettier.d.ts(new, hand-written) and the export becomes:typescript-eslint's composed flat-config types tripTS2742("inferred type cannot be named"). The Prettier config is a simple object, so a small declaration covers it. This is why only/prettierships types for now.package.json—filesnow includestypes.tsconfig.json—excludeaddstypes(the hand-written.d.tsisn't a tsc input).eslint.config.mjs(repo's own) — ignorestypes/:@typescript-eslint/unified-signaturescrashes 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 theeslint-config-prettiercomment (readability; matches vscode-extension).Verification (clean-room A/B)
Plus
npm run lint/npm test/npm run publintall green.Rollout
Ships in
3.0.0-beta.3. After publish, vscode-extension'sprettier.config.mjssquiggle clears once it bumps to beta.3 (no code change needed there).Known limitation
The
/typescript,/legacy,/reactexports still ship no types (sameTS2742blocker). A consumer importing those in a type-checked context could seets(7016); flat eslint configs are usually.mjsexcluded fromtsc, so this is rarely hit. Typing those would need explicit annotations on the config arrays — out of scope here.