-
Notifications
You must be signed in to change notification settings - Fork 82
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
chore: support typescript #117
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,22 @@ | ||||||
import inquirer, { Answers } from 'inquirer'; | ||||||
|
||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As it is, I get this error when trying your branch: error TS2345: Argument of type 'typeof import("./node_modules/inquirer-autocomplete-prompt/index")' is not assignable to parameter of type 'PromptConstructor'.
Type 'typeof import("./node_modules/inquirer-autocomplete-prompt/index")' provides no match for the signature 'new (question: any, readLine: Interface, answers: Answers): PromptBase'.
10 inquirer.registerPrompt(`autocomplete`, autocomplete) This is my {
"extends": "@tsconfig/node12/tsconfig.json",
"compilerOptions": {
"esModuleInterop": true,
"moduleResolution": "node",
"strict": true,
"outDir": "./.transpiled",
"noUncheckedIndexedAccess": true,
"noPropertyAccessFromIndexSignature": true,
},
"include": [ "./" ],
} It seems to me that this file is missing the actual export types, please verify and fix. export default interface InquirerAutocompletePrompt {}
declare var inquirerAutocompletePrompt: InquirerAutocompletePrompt;
export = inquirerAutocompletePrompt; I added that 👆 to the end of this file and the error changed to this 👇 error TS2345: Argument of type 'InquirerAutocompletePrompt' is not assignable to parameter of type 'PromptConstructor'.
Type 'InquirerAutocompletePrompt' provides no match for the signature 'new (question: any, readLine: Interface, answers: Answers): PromptBase'.
10 inquirer.registerPrompt(`autocomplete`, autocomplete) Note how |
||||||
declare module 'inquirer' { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To extend the inquirer interfaces, this seems more appropriate to get alignment:
Suggested change
See https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/inquirer/index.d.ts#L95 Note: So far, I have not typed across packages myself, so I may be missing something. This comment is really based only on my observation in |
||||||
interface AutocompleteQuestionOptions<T> extends Question<T> { | ||||||
suggestOnly?: boolean; | ||||||
searchText?: string; | ||||||
emptyText?: string; | ||||||
default?: string; | ||||||
pageSize?: number; | ||||||
filter?(options: Array<string>): Array<string>; | ||||||
validate?(line: string): boolean; | ||||||
source(answersSoFar: Answers, input: string): Promise<Array<string>>; | ||||||
} | ||||||
|
||||||
export interface AutocompleteQuestion<T extends Answers = Answers> extends AutocompleteQuestionOptions<T> { | ||||||
type: "autocomplete"; | ||||||
} | ||||||
|
||||||
export interface QuestionMap<T extends Answers = Answers> { | ||||||
autocomplete: AutocompleteQuestion<T>; | ||||||
} | ||||||
} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mind the final newline 😉 It's better for the diffs. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this change. See the docs:
Besides,
"types": "index.d.ts",
inpackage.json
already provides the types.