Open awhitford opened 2 months ago
I defined a new derived type like so
type ActionsConfig =
| PlopTypes.ActionConfig
| PlopTypes.AddActionConfig
| PlopTypes.AddManyActionConfig
| PlopTypes.AppendActionConfig
| PlopTypes.ModifyActionConfig;
and used it in the function similar to what you have done
actions: (data) => {
var actionsToRun: ActionsConfig[] = [];
if (data && data.confirm) {
actionsToRun.push({
type: 'add',
path: 'src/helpers/{{kebabCase helper_file_name}}.ts',
templateFile: 'templates/helper.hbs',
skipIfExists: true,
});
} else {
console.log('Helper generation aborted');
}
return actionsToRun;
}
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