plop: TypeScript - Missing type in ActionType

Hello,

I’m trying to use plop with TypeScript, and I’m getting the following error.

Type '{ type: string; path: string; templateFile: string; }' is not assignable to type 'ActionType'.
  Type '{ type: string; path: string; templateFile: string; }' is missing the following properties from type 'AppendActionConfig': pattern, unique, separator, template, and 3 more.ts(2322)

My plopfile.ts

import { NodePlopAPI } from "plop";

export default function(plop: NodePlopAPI) {
    // controller generator
    plop.setGenerator("controller", {
        description: "application controller logic",
        prompts: [
            {
                type: "input",
                name: "name",
                message: "controller name please"
            }
        ],
        actions: [
            {
                type: "add",
                path: "src/{{name}}.js",
                templateFile: "plop-templates/controller.hbs"
            }
        ]
    });
}

Image

image

(GUESS) Apparently the ActionType lacks the AddActionConfig interface:

export type ActionType =
  | ActionConfig
  | AddManyActionConfig
  | ModifyActionConfig
  | AppendActionConfig
  | CustomActionFunction;

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 20 (17 by maintainers)

Most upvoted comments

Ok then, so that’s what I will do:

  • Adding the AddActionConfig in the ActionType type;
  • Setting the optionals/default values in the action types in respect with the docs;
  • Review the file and try to identify another situations.

I will ping you when it’s done.

Work’s rough for me right now, so I can’t write PRs. I can probably review them.