Skip to content

Commit

Permalink
Fix unique symbol error (#248)
Browse files Browse the repository at this point in the history
* replace unique symbol with uuid v4

Ideally we can use a Symbol, however it seems that TypeScript or TSDX,
inlines the `unique symbol`, instead of referencing the actual __
placeholder type.

Ideally we add this back in the future, but the odds that somebody has
this specific uuid in production is close to 0. (Unless they
specifically use this uuid).

Fixes: #240

Thanks to =?UTF-8?q?Micha=C3=ABl=20Zasso?= <[email protected]> for
providing a reproduction repository!

* update changelog
  • Loading branch information
RobinMalfait authored Feb 19, 2021
1 parent a94cc79 commit c4549e4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Fixed `outside click` not re-focusing the `Menu.Button` ([#220](https://github.com/tailwindlabs/headlessui/pull/220))
- Fixed `outside click` not re-focusing the `Listbox.Button` ([#220](https://github.com/tailwindlabs/headlessui/pull/220))
- Fix incorrect type error `unique symbol` ([#248](https://github.com/tailwindlabs/headlessui/pull/248), [#240](https://github.com/tailwindlabs/headlessui/issues/240))

### Added

Expand Down
6 changes: 4 additions & 2 deletions packages/@headlessui-react/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { ReactNode, ReactElement } from 'react'
// A unique placeholder we can use as some defaults. This is nice because we can use this instead of

// A unique placeholder we can use as a default. This is nice because we can use this instead of
// defaulting to null / never / ... and possibly collide with actual data.
const __: unique symbol = Symbol('__placeholder__')
// Ideally we use a unique symbol here.
let __ = '1D45E01E-AF44-47C4-988A-19A94EBAF55C' as const
export type __ = typeof __

export type Expand<T> = T extends infer O ? { [K in keyof O]: O[K] } : never
Expand Down

0 comments on commit c4549e4

Please sign in to comment.