anc95 / inquirer-file-tree-selection

inquirer prompt for select a file or dir by file tree
49 stars 26 forks source link

Typescript support #51

Closed AmauryLiet closed 2 years ago

AmauryLiet commented 2 years ago

Hello,

First of all thanks for the great inquirer module, it really helps making a great cli experience

I raise the question of TypeScript support, which would make integrating the plugin smoother. Hoping to find time to provide the PR shortly

if anyone is willing to add the type.d.ts file and test the change on its side, here is some base material:

interface FileTreeQuestionOptions<Answers> {
  type: 'file-tree-selection';
  name: keyof Answers;
  message: string;
  filter?: (path: string) => Promise<string> | string;
  validate?: (filteredPath: string, answers: unknown) => boolean;
  transformer?: (directoryName: string, answers: Answers, context: { isFinal: boolean }) => string;
  pageSize?: number;
  onlyShowDir?: boolean;
  onlyShowValid?: boolean;
  hideChildrenOfValid?: boolean;
  root?: string;
  hideRoot?: boolean;
  multiple?: boolean;
  default?: string | string[];
}

(this could be improved by binding multiple & default typings)

Thanks!

anc95 commented 2 years ago

Thank you very much! I will add it these days when got time.

anc95 commented 2 years ago

@AmauryLiet Hello, typescript is supported in the new release version 1.0.16. More guide is in here