You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using plopjs and was having a great time until I decided to migrate to TypeScript (because I like types). What is the advice for using a Dynamic Actions Array like this in TypeScript?
actions: (answers)=>{}
Inside the closure, I want to be able to reference the prompts like: answers.projectName.
If I create an interface for the prompt parameters, like:
interfacePromptProps{projectName: string}
Then, I can add type information like this:
actions: (answers: PromptProps) => {
}
While this solves the answers.projectName problem, Typescript still complains about the actions declaration:
Type '(answers: PromptProps) => (string | ((answers: PromptProps) => string) | { type: string; path: string; pattern: RegExp; template: string; })[]' is not assignable to type 'Actions | undefined'.
Type '(answers: PromptProps) => (string | ((answers: PromptProps) => string) | { type: string; path: string; pattern: RegExp; template: string; })[]' is not assignable to type 'DynamicActionsFunction'.
Types of parameters 'answers' and 'data' are incompatible.
Type 'Answers | undefined' is not assignable to type 'PromptProps'.
Type 'undefined' is not assignable to type 'PromptProps'.ts(2322)
I am using plopjs and was having a great time until I decided to migrate to TypeScript (because I like types).
What is the advice for using a Dynamic Actions Array like this in TypeScript?
Inside the closure, I want to be able to reference the prompts like:
answers.projectName
.If I create an interface for the prompt parameters, like:
Then, I can add type information like this:
While this solves the
answers.projectName
problem, Typescript still complains about theactions
declaration:What is the solution?
CC: @crutchcorn @cspotcode
The text was updated successfully, but these errors were encountered: