Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add type declarations #1259

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
declare module 'ember-shepherd/services/tour' {
import Shepherd from 'shepherd.js';

export interface TourButton extends Shepherd.Step.StepOptionsButton {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This interface isn't really part of the tour service, but is needed because the default Shepard.js button type does not have a type property

type: 'next' | 'back' | 'cancel';
}

interface RequiredElement {
selector: string;
message: string;
title: string;
}

export default interface Tour {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@charlesfries could we import these types from Shepherd itself?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Tour class type here https://github.com/shipshapecode/shepherd/blob/master/src/types/tour.d.ts seems to be pretty similar, but there are methods like addStep() that exist in the Shepherd Tour class that don't exist in the Tour Ember service.

Definitely open to figuring out how to use those types and avoid duplication, but IMO the Tour object and Tour service may need to be distinct.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@charlesfries I'm not super experienced with TS, but I was hoping we could merge them into one. Perhaps the ember-shepherd one can extend the Shepherd ones and add more things?

classPrefix: string;
confirmCancel: boolean;
confirmCancelMessage: string | null;
defaultStepOptions: Record<string, unknown>;
errorTitle: string | null;
exitOnEsc: boolean;
isActive: boolean;
keyboardNavigation: boolean;
messageForUser: string | null;
modal: boolean;
modalContainer: HTMLElement;
requiredElements: RequiredElement[];
steps: Shepherd.Step[];
addSteps: (steps: Shepherd.Step.StepOptions[]) => void;
back: () => void;
cancel: () => void;
complete: () => void;
hide: () => void;
next: () => void;
show: (id: string) => void;
start: () => void;
_onTourStart: () => void;
_onTourFinish: (completeOrCancel: string) => void;
_initialize: () => void;
_requiredElementsPresent: () => boolean;
}
}