Skip to content

Commit 2c0965b

Browse files
Remove declare to clean up global scope (#354)
* refactor(types): Remove dangerous `declare` so prettier types aren't polluted globally * add docs example * Update changelog * Tweak readme * Adjust internal types --------- Co-authored-by: Jordan Pittman <[email protected]>
1 parent 65d0049 commit 2c0965b

File tree

5 files changed

+15
-8
lines changed

5 files changed

+15
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10-
- Nothing yet!
10+
- Don't augment global Prettier `ParserOptions` and `RequiredOptions` types ([#354](https://github.com/tailwindlabs/prettier-plugin-tailwindcss/pull/354))
1111

1212
## [0.6.14] - 2025-07-09
1313

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,17 @@ Then add the plugin to your [Prettier configuration](https://prettier.io/docs/en
1919
}
2020
```
2121

22+
When using a JavaScript config, you can import the types for IntelliSense:
23+
24+
```js
25+
// prettier.config.js
26+
27+
/** @type {import('prettier').Config & import('prettier-plugin-tailwindcss').PluginOptions} */
28+
export default {
29+
plugins: ["prettier-plugin-tailwindcss"],
30+
}
31+
```
32+
2233
## Upgrading to v0.5.x
2334

2435
As of v0.5.x, this plugin now requires Prettier v3 and is ESM-only. This means it cannot be loaded via `require()`. For more information see our [upgrade guide](https://github.com/tailwindlabs/prettier-plugin-tailwindcss/issues/207#issuecomment-1698071122).

src/index.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,8 +1288,3 @@ export interface PluginOptions {
12881288
*/
12891289
tailwindPreserveDuplicates?: boolean
12901290
}
1291-
1292-
declare module 'prettier' {
1293-
interface RequiredOptions extends PluginOptions {}
1294-
interface ParserOptions extends PluginOptions {}
1295-
}

src/internal.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
export interface InternalOptions {
1+
import type { PluginOptions } from '.'
2+
3+
export interface InternalOptions extends PluginOptions {
24
printer: Printer<any>
35

46
/**

src/options.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type { RequiredOptions, SupportOption } from 'prettier'
22
import type { Customizations } from './types'
3-
import './index'
43

54
export const options: Record<string, SupportOption> = {
65
tailwindConfig: {

0 commit comments

Comments
 (0)