Skip to content

Commit

Permalink
Fix type of settings if nothing is registered yet
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Aug 20, 2023
1 parent 9ba8e23 commit cea788b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
8 changes: 6 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ export type {

export {unified} from './lib/index.js'

// See: <https://github.com/sindresorhus/type-fest/blob/main/source/empty-object.d.ts>
declare const emptyObjectSymbol: unique symbol

/**
* Interface of known results from compilers.
*
Expand Down Expand Up @@ -98,5 +101,6 @@ export interface Data {
* export {} // You may not need this, but it makes sure the file is a module.
* ```
*/
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface Settings {}
export interface Settings {
[emptyObjectSymbol]?: never
}
13 changes: 9 additions & 4 deletions index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,10 +464,6 @@ declare module './index.js' {
interface CompileResultMap {
ReactNode: ReactNode
}

interface Data {
something?: string | undefined
}
}

// Compile plugin (to a non-node).
Expand Down Expand Up @@ -552,6 +548,15 @@ expectType<Processor>(
})
)

/**
* Register our setting.
*/
declare module './index.js' {
interface Settings {
something?: string | undefined
}
}

expectType<Processor>(
unified().use({
plugins: [
Expand Down

0 comments on commit cea788b

Please sign in to comment.