Skip to content

Commit

Permalink
docs(plugins): use type filter to prevent name conflicts
Browse files Browse the repository at this point in the history
Resolves #631
  • Loading branch information
atomiks committed Nov 4, 2019
1 parent 6debf2b commit b571014
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions website/src/pages/plugins.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,20 @@ state in the plugin closure. This is how the `followCursor` plugin works.

### TypeScript

Interfaces that take `Props` are generics that accept an extended interface:
Types that take `Props` (e.g. `Tippy`, `Delegate`, `CreateSingleton`) are
generics that accept an extended props interface:

```ts
import tippy, {Props, Plugin, LifecycleHooks} from 'tippy.js';
import tippy, {Tippy, Props, Plugin, LifecycleHooks} from 'tippy.js';

// Your custom plugin types
interface CustomProps extends Omit<Props, keyof LifecycleHooks> {
interface CustomProps {
myCustomProp: boolean;
}

export type ExtendedProps = CustomProps & LifecycleHooks<CustomProps>;
type FilteredProps = CustomProps &
Omit<Props, keyof CustomProps | keyof LifecycleHooks>;

type ExtendedProps = FilteredProps & LifecycleHooks<FilteredProps>;

export const myCustomProp: Plugin<ExtendedProps> = {
name: 'myCustomProp',
Expand Down

0 comments on commit b571014

Please sign in to comment.